1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instsimplify -S | FileCheck %s
6 define double @fadd_nan_op0(double %x) {
7 ; CHECK-LABEL: @fadd_nan_op0(
8 ; CHECK-NEXT: ret double 0x7FF8000000000000
10 %r = fadd double 0x7FF8000000000000, %x
16 define double @fadd_nan_op1(double %x) {
17 ; CHECK-LABEL: @fadd_nan_op1(
18 ; CHECK-NEXT: ret double 0xFFF8000000000000
20 %r = fadd double %x, 0xFFF8000000000000
26 define float @fsub_nan_op0(float %x) {
27 ; CHECK-LABEL: @fsub_nan_op0(
28 ; CHECK-NEXT: ret float 0x7FFFFF0000000000
30 %r = fsub float 0x7FFFFF0000000000, %x
36 define float @fsub_nan_op1(float %x) {
37 ; CHECK-LABEL: @fsub_nan_op1(
38 ; CHECK-NEXT: ret float 0x7FF1000000000000
40 %r = fsub float %x, 0x7FF1000000000000
44 ; Signaling and signed
46 define double @fmul_nan_op0(double %x) {
47 ; CHECK-LABEL: @fmul_nan_op0(
48 ; CHECK-NEXT: ret double 0xFFF0000000000001
50 %r = fmul double 0xFFF0000000000001, %x
56 define <2 x float> @fmul_nan_op1(<2 x float> %x) {
57 ; CHECK-LABEL: @fmul_nan_op1(
58 ; CHECK-NEXT: ret <2 x float> <float 0x7FF8000000000000, float 0x7FF8000000000000>
60 %r = fmul <2 x float> %x, <float 0x7FF8000000000000, float 0x7FF8000000000000>
64 ; Vector signed and non-zero payload
66 define <2 x double> @fdiv_nan_op0(<2 x double> %x) {
67 ; CHECK-LABEL: @fdiv_nan_op0(
68 ; CHECK-NEXT: ret <2 x double> <double 0xFFF800000000000F, double 0xFFF800000000000F>
70 %r = fdiv <2 x double> <double 0xFFF800000000000F, double 0xFFF800000000000F>, %x
74 ; Vector with different NaN constant elements
76 define <2 x half> @fdiv_nan_op1(<2 x half> %x) {
77 ; CHECK-LABEL: @fdiv_nan_op1(
78 ; CHECK-NEXT: ret <2 x half> <half 0xH7FFF, half 0xHFF00>
80 %r = fdiv <2 x half> %x, <half 0xH7FFF, half 0xHFF00>
84 ; Vector with undef element
86 define <2 x double> @frem_nan_op0(<2 x double> %x) {
87 ; CHECK-LABEL: @frem_nan_op0(
88 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>
90 %r = frem <2 x double> <double 0xFFFF000000000000, double undef>, %x
94 define float @frem_nan_op1(float %x) {
95 ; CHECK-LABEL: @frem_nan_op1(
96 ; CHECK-NEXT: ret float 0x7FF8000000000000
98 %r = frem float %x, 0x7FF8000000000000
102 ; Special-case: fneg must only change the sign bit (this is handled by constant folding).
104 define double @fneg_nan_1(double %x) {
105 ; CHECK-LABEL: @fneg_nan_1(
106 ; CHECK-NEXT: ret double 0xFFFABCDEF0123456
108 %r = fsub double -0.0, 0x7FFABCDEF0123456
112 define double @unary_fneg_nan_1(double %x) {
113 ; CHECK-LABEL: @unary_fneg_nan_1(
114 ; CHECK-NEXT: ret double 0xFFFABCDEF0123456
116 %r = fneg double 0x7FFABCDEF0123456
120 define <2 x double> @fneg_nan_2(<2 x double> %x) {
121 ; CHECK-LABEL: @fneg_nan_2(
122 ; CHECK-NEXT: ret <2 x double> <double 0x7FF1234567890ABC, double 0xFFF0000000000001>
124 %r = fsub <2 x double> <double -0.0, double -0.0>, <double 0xFFF1234567890ABC, double 0x7FF0000000000001>
128 define <2 x double> @unary_fneg_nan_2(<2 x double> %x) {
129 ; CHECK-LABEL: @unary_fneg_nan_2(
130 ; CHECK-NEXT: ret <2 x double> <double 0x7FF1234567890ABC, double 0xFFF0000000000001>
132 %r = fneg <2 x double> <double 0xFFF1234567890ABC, double 0x7FF0000000000001>
136 ; Repeat all tests with fast-math-flags. Alternate 'nnan' and 'fast' for more coverage.
138 define float @fadd_nan_op0_nnan(float %x) {
139 ; CHECK-LABEL: @fadd_nan_op0_nnan(
140 ; CHECK-NEXT: ret float 0x7FF8000000000000
142 %r = fadd nnan float 0x7FF8000000000000, %x
146 define float @fadd_nan_op1_fast(float %x) {
147 ; CHECK-LABEL: @fadd_nan_op1_fast(
148 ; CHECK-NEXT: ret float 0x7FF8000000000000
150 %r = fadd fast float %x, 0x7FF8000000000000
154 define float @fsub_nan_op0_fast(float %x) {
155 ; CHECK-LABEL: @fsub_nan_op0_fast(
156 ; CHECK-NEXT: ret float 0x7FF8000000000000
158 %r = fsub fast float 0x7FF8000000000000, %x
162 define float @fsub_nan_op1_nnan(float %x) {
163 ; CHECK-LABEL: @fsub_nan_op1_nnan(
164 ; CHECK-NEXT: ret float 0x7FF8000000000000
166 %r = fsub nnan float %x, 0x7FF8000000000000
170 define float @fmul_nan_op0_nnan(float %x) {
171 ; CHECK-LABEL: @fmul_nan_op0_nnan(
172 ; CHECK-NEXT: ret float 0x7FF8000000000000
174 %r = fmul nnan float 0x7FF8000000000000, %x
178 define float @fmul_nan_op1_fast(float %x) {
179 ; CHECK-LABEL: @fmul_nan_op1_fast(
180 ; CHECK-NEXT: ret float 0x7FF8000000000000
182 %r = fmul fast float %x, 0x7FF8000000000000
186 define float @fdiv_nan_op0_fast(float %x) {
187 ; CHECK-LABEL: @fdiv_nan_op0_fast(
188 ; CHECK-NEXT: ret float 0x7FF8000000000000
190 %r = fdiv fast float 0x7FF8000000000000, %x
194 define float @fdiv_nan_op1_nnan(float %x) {
195 ; CHECK-LABEL: @fdiv_nan_op1_nnan(
196 ; CHECK-NEXT: ret float 0x7FF8000000000000
198 %r = fdiv nnan float %x, 0x7FF8000000000000
202 define float @frem_nan_op0_nnan(float %x) {
203 ; CHECK-LABEL: @frem_nan_op0_nnan(
204 ; CHECK-NEXT: ret float 0x7FF8000000000000
206 %r = frem nnan float 0x7FF8000000000000, %x
210 define float @frem_nan_op1_fast(float %x) {
211 ; CHECK-LABEL: @frem_nan_op1_fast(
212 ; CHECK-NEXT: ret float 0x7FF8000000000000
214 %r = frem fast float %x, 0x7FF8000000000000