1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instsimplify -S | FileCheck %s
12 define float @fadd_x_n0_defaultenv(float %a) #0 {
13 ; CHECK-LABEL: @fadd_x_n0_defaultenv(
14 ; CHECK-NEXT: ret float [[A:%.*]]
16 %ret = call float @llvm.experimental.constrained.fadd.f32(float %a, float -0.0, metadata !"round.tonearest", metadata !"fpexcept.ignore") #0
20 define <2 x float> @fadd_vec_x_n0_defaultenv(<2 x float> %a) #0 {
21 ; CHECK-LABEL: @fadd_vec_x_n0_defaultenv(
22 ; CHECK-NEXT: ret <2 x float> [[A:%.*]]
24 %ret = call <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> %a, <2 x float><float -0.0, float -0.0>, metadata !"round.tonearest", metadata !"fpexcept.ignore") #0
28 define float @fadd_x_n0_ebmaytrap(float %a) #0 {
29 ; CHECK-LABEL: @fadd_x_n0_ebmaytrap(
30 ; CHECK-NEXT: [[RET:%.*]] = call float @llvm.experimental.constrained.fadd.f32(float [[A:%.*]], float -0.000000e+00, metadata !"round.tonearest", metadata !"fpexcept.maytrap") #[[ATTR0:[0-9]+]]
31 ; CHECK-NEXT: ret float [[RET]]
33 %ret = call float @llvm.experimental.constrained.fadd.f32(float %a, float -0.0, metadata !"round.tonearest", metadata !"fpexcept.maytrap") #0
37 define <2 x float> @fadd_vec_x_n0_ebmaytrap(<2 x float> %a) #0 {
38 ; CHECK-LABEL: @fadd_vec_x_n0_ebmaytrap(
39 ; CHECK-NEXT: [[RET:%.*]] = call <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> [[A:%.*]], <2 x float> <float -0.000000e+00, float -0.000000e+00>, metadata !"round.tonearest", metadata !"fpexcept.maytrap") #[[ATTR0]]
40 ; CHECK-NEXT: ret <2 x float> [[RET]]
42 %ret = call <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> %a, <2 x float><float -0.0, float -0.0>, metadata !"round.tonearest", metadata !"fpexcept.maytrap") #0
46 define float @fadd_x_n0_ebstrict(float %a) #0 {
47 ; CHECK-LABEL: @fadd_x_n0_ebstrict(
48 ; CHECK-NEXT: [[RET:%.*]] = call float @llvm.experimental.constrained.fadd.f32(float [[A:%.*]], float -0.000000e+00, metadata !"round.tonearest", metadata !"fpexcept.strict") #[[ATTR0]]
49 ; CHECK-NEXT: ret float [[RET]]
51 %ret = call float @llvm.experimental.constrained.fadd.f32(float %a, float -0.0, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
55 define <2 x float> @fadd_vec_x_n0_ebstrict(<2 x float> %a) #0 {
56 ; CHECK-LABEL: @fadd_vec_x_n0_ebstrict(
57 ; CHECK-NEXT: [[RET:%.*]] = call <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> [[A:%.*]], <2 x float> <float -0.000000e+00, float -0.000000e+00>, metadata !"round.tonearest", metadata !"fpexcept.strict") #[[ATTR0]]
58 ; CHECK-NEXT: ret <2 x float> [[RET]]
60 %ret = call <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> %a, <2 x float><float -0.0, float -0.0>, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
64 define float @fadd_x_n0_neginf(float %a) #0 {
65 ; CHECK-LABEL: @fadd_x_n0_neginf(
66 ; CHECK-NEXT: [[RET:%.*]] = call float @llvm.experimental.constrained.fadd.f32(float [[A:%.*]], float -0.000000e+00, metadata !"round.downward", metadata !"fpexcept.ignore") #[[ATTR0]]
67 ; CHECK-NEXT: ret float [[RET]]
69 %ret = call float @llvm.experimental.constrained.fadd.f32(float %a, float -0.0, metadata !"round.downward", metadata !"fpexcept.ignore") #0
73 define <2 x float> @fadd_vec_x_n0_neginf(<2 x float> %a) #0 {
74 ; CHECK-LABEL: @fadd_vec_x_n0_neginf(
75 ; CHECK-NEXT: [[RET:%.*]] = call <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> [[A:%.*]], <2 x float> <float -0.000000e+00, float -0.000000e+00>, metadata !"round.downward", metadata !"fpexcept.ignore") #[[ATTR0]]
76 ; CHECK-NEXT: ret <2 x float> [[RET]]
78 %ret = call <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> %a, <2 x float><float -0.0, float -0.0>, metadata !"round.downward", metadata !"fpexcept.ignore") #0
82 define float @fadd_x_n0_dynamic(float %a) #0 {
83 ; CHECK-LABEL: @fadd_x_n0_dynamic(
84 ; CHECK-NEXT: [[RET:%.*]] = call float @llvm.experimental.constrained.fadd.f32(float [[A:%.*]], float -0.000000e+00, metadata !"round.dynamic", metadata !"fpexcept.ignore") #[[ATTR0]]
85 ; CHECK-NEXT: ret float [[RET]]
87 %ret = call float @llvm.experimental.constrained.fadd.f32(float %a, float -0.0, metadata !"round.dynamic", metadata !"fpexcept.ignore") #0
91 define <2 x float> @fadd_vec_x_n0_dynamic(<2 x float> %a) #0 {
92 ; CHECK-LABEL: @fadd_vec_x_n0_dynamic(
93 ; CHECK-NEXT: [[RET:%.*]] = call <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> [[A:%.*]], <2 x float> <float -0.000000e+00, float -0.000000e+00>, metadata !"round.dynamic", metadata !"fpexcept.ignore") #[[ATTR0]]
94 ; CHECK-NEXT: ret <2 x float> [[RET]]
96 %ret = call <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> %a, <2 x float><float -0.0, float -0.0>, metadata !"round.dynamic", metadata !"fpexcept.ignore") #0
100 ; The rounding mode here needs to not be { tonearest, downward, dynamic }.
101 ; Test one of the remaining rounding modes and the rest will be fine.
102 define float @fadd_x_n0_towardzero(float %a) #0 {
103 ; CHECK-LABEL: @fadd_x_n0_towardzero(
104 ; CHECK-NEXT: [[RET:%.*]] = call float @llvm.experimental.constrained.fadd.f32(float [[A:%.*]], float -0.000000e+00, metadata !"round.towardzero", metadata !"fpexcept.ignore") #[[ATTR0]]
105 ; CHECK-NEXT: ret float [[RET]]
107 %ret = call float @llvm.experimental.constrained.fadd.f32(float %a, float -0.0, metadata !"round.towardzero", metadata !"fpexcept.ignore") #0
111 ; The rounding mode here needs to not be { tonearest, downward, dynamic }.
112 ; Test one of the remaining rounding modes and the rest will be fine.
113 define <2 x float> @fadd_vec_x_n0_towardzero(<2 x float> %a) #0 {
114 ; CHECK-LABEL: @fadd_vec_x_n0_towardzero(
115 ; CHECK-NEXT: [[RET:%.*]] = call <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> [[A:%.*]], <2 x float> <float -0.000000e+00, float -0.000000e+00>, metadata !"round.towardzero", metadata !"fpexcept.ignore") #[[ATTR0]]
116 ; CHECK-NEXT: ret <2 x float> [[RET]]
118 %ret = call <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> %a, <2 x float><float -0.0, float -0.0>, metadata !"round.towardzero", metadata !"fpexcept.ignore") #0
122 define float @fadd_nnan_x_n0_ebstrict(float %a) #0 {
123 ; CHECK-LABEL: @fadd_nnan_x_n0_ebstrict(
124 ; CHECK-NEXT: [[RET:%.*]] = call nnan float @llvm.experimental.constrained.fadd.f32(float [[A:%.*]], float -0.000000e+00, metadata !"round.tonearest", metadata !"fpexcept.strict") #[[ATTR0]]
125 ; CHECK-NEXT: ret float [[RET]]
127 %ret = call nnan float @llvm.experimental.constrained.fadd.f32(float %a, float -0.0, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
131 define <2 x float> @fadd_vec_nnan_x_n0_ebstrict(<2 x float> %a) #0 {
132 ; CHECK-LABEL: @fadd_vec_nnan_x_n0_ebstrict(
133 ; CHECK-NEXT: [[RET:%.*]] = call nnan <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> [[A:%.*]], <2 x float> <float -0.000000e+00, float -0.000000e+00>, metadata !"round.tonearest", metadata !"fpexcept.strict") #[[ATTR0]]
134 ; CHECK-NEXT: ret <2 x float> [[RET]]
136 %ret = call nnan <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> %a, <2 x float><float -0.0, float -0.0>, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
140 ; Test with a fast math flag set but that flag is not "nnan".
141 define float @fadd_ninf_x_n0_ebstrict(float %a) #0 {
142 ; CHECK-LABEL: @fadd_ninf_x_n0_ebstrict(
143 ; CHECK-NEXT: [[RET:%.*]] = call ninf float @llvm.experimental.constrained.fadd.f32(float [[A:%.*]], float -0.000000e+00, metadata !"round.tonearest", metadata !"fpexcept.strict") #[[ATTR0]]
144 ; CHECK-NEXT: ret float [[RET]]
146 %ret = call ninf float @llvm.experimental.constrained.fadd.f32(float %a, float -0.0, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
150 ; Test with a fast math flag set but that flag is not "nnan".
151 define <2 x float> @fadd_vec_ninf_x_n0_ebstrict(<2 x float> %a) #0 {
152 ; CHECK-LABEL: @fadd_vec_ninf_x_n0_ebstrict(
153 ; CHECK-NEXT: [[RET:%.*]] = call ninf <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> [[A:%.*]], <2 x float> <float -0.000000e+00, float -0.000000e+00>, metadata !"round.tonearest", metadata !"fpexcept.strict") #[[ATTR0]]
154 ; CHECK-NEXT: ret <2 x float> [[RET]]
156 %ret = call ninf <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> %a, <2 x float><float -0.0, float -0.0>, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
160 define float @fadd_n0_x_defaultenv(float %a) #0 {
161 ; CHECK-LABEL: @fadd_n0_x_defaultenv(
162 ; CHECK-NEXT: ret float [[A:%.*]]
164 %ret = call float @llvm.experimental.constrained.fadd.f32(float -0.0, float %a, metadata !"round.tonearest", metadata !"fpexcept.ignore") #0
168 define <2 x float> @fadd_vec_n0_x_defaultenv(<2 x float> %a) #0 {
169 ; CHECK-LABEL: @fadd_vec_n0_x_defaultenv(
170 ; CHECK-NEXT: ret <2 x float> [[A:%.*]]
172 %ret = call <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float><float -0.0, float -0.0>, <2 x float> %a, metadata !"round.tonearest", metadata !"fpexcept.ignore") #0
176 ; TODO: Canonicalize the order of the arguments. Then this will fire.
177 define float @fadd_n0_x_ebmaytrap(float %a) #0 {
178 ; CHECK-LABEL: @fadd_n0_x_ebmaytrap(
179 ; CHECK-NEXT: [[RET:%.*]] = call float @llvm.experimental.constrained.fadd.f32(float -0.000000e+00, float [[A:%.*]], metadata !"round.tonearest", metadata !"fpexcept.maytrap") #[[ATTR0]]
180 ; CHECK-NEXT: ret float [[RET]]
182 %ret = call float @llvm.experimental.constrained.fadd.f32(float -0.0, float %a, metadata !"round.tonearest", metadata !"fpexcept.maytrap") #0
186 ; TODO: Canonicalize the order of the arguments. Then this will fire.
187 define <2 x float> @fadd_vec_n0_x_ebmaytrap(<2 x float> %a) #0 {
188 ; CHECK-LABEL: @fadd_vec_n0_x_ebmaytrap(
189 ; CHECK-NEXT: [[RET:%.*]] = call <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> <float -0.000000e+00, float -0.000000e+00>, <2 x float> [[A:%.*]], metadata !"round.tonearest", metadata !"fpexcept.maytrap") #[[ATTR0]]
190 ; CHECK-NEXT: ret <2 x float> [[RET]]
192 %ret = call <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float><float -0.0, float -0.0>, <2 x float> %a, metadata !"round.tonearest", metadata !"fpexcept.maytrap") #0
197 ; fadd X, 0 ==> X, when we know X is not -0
200 define float @fold_fadd_nsz_x_0_defaultenv(float %a) #0 {
201 ; CHECK-LABEL: @fold_fadd_nsz_x_0_defaultenv(
202 ; CHECK-NEXT: ret float [[A:%.*]]
204 %add = call nsz float @llvm.experimental.constrained.fadd.f32(float %a, float 0.0, metadata !"round.tonearest", metadata !"fpexcept.ignore") #0
208 define <2 x float> @fold_fadd_vec_nsz_x_0_defaultenv(<2 x float> %a) #0 {
209 ; CHECK-LABEL: @fold_fadd_vec_nsz_x_0_defaultenv(
210 ; CHECK-NEXT: ret <2 x float> [[A:%.*]]
212 %add = call nsz <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> %a, <2 x float> zeroinitializer, metadata !"round.tonearest", metadata !"fpexcept.ignore") #0
216 define float @fold_fadd_nsz_x_0_ebmaytrap(float %a) #0 {
217 ; CHECK-LABEL: @fold_fadd_nsz_x_0_ebmaytrap(
218 ; CHECK-NEXT: [[ADD:%.*]] = call nsz float @llvm.experimental.constrained.fadd.f32(float [[A:%.*]], float 0.000000e+00, metadata !"round.tonearest", metadata !"fpexcept.maytrap") #[[ATTR0]]
219 ; CHECK-NEXT: ret float [[ADD]]
221 %add = call nsz float @llvm.experimental.constrained.fadd.f32(float %a, float 0.0, metadata !"round.tonearest", metadata !"fpexcept.maytrap") #0
225 define <2 x float> @fold_fadd_vec_nsz_x_0_ebmaytrap(<2 x float> %a) #0 {
226 ; CHECK-LABEL: @fold_fadd_vec_nsz_x_0_ebmaytrap(
227 ; CHECK-NEXT: [[ADD:%.*]] = call nsz <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> [[A:%.*]], <2 x float> zeroinitializer, metadata !"round.tonearest", metadata !"fpexcept.maytrap") #[[ATTR0]]
228 ; CHECK-NEXT: ret <2 x float> [[ADD]]
230 %add = call nsz <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> %a, <2 x float> zeroinitializer, metadata !"round.tonearest", metadata !"fpexcept.maytrap") #0
234 define float @fold_fadd_nsz_x_0_ebstrict(float %a) #0 {
235 ; CHECK-LABEL: @fold_fadd_nsz_x_0_ebstrict(
236 ; CHECK-NEXT: [[ADD:%.*]] = call nsz float @llvm.experimental.constrained.fadd.f32(float [[A:%.*]], float 0.000000e+00, metadata !"round.tonearest", metadata !"fpexcept.strict") #[[ATTR0]]
237 ; CHECK-NEXT: ret float [[ADD]]
239 %add = call nsz float @llvm.experimental.constrained.fadd.f32(float %a, float 0.0, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
243 define <2 x float> @fold_fadd_vec_nsz_x_0_ebstrict(<2 x float> %a) #0 {
244 ; CHECK-LABEL: @fold_fadd_vec_nsz_x_0_ebstrict(
245 ; CHECK-NEXT: [[ADD:%.*]] = call nsz <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> [[A:%.*]], <2 x float> zeroinitializer, metadata !"round.tonearest", metadata !"fpexcept.strict") #[[ATTR0]]
246 ; CHECK-NEXT: ret <2 x float> [[ADD]]
248 %add = call nsz <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> %a, <2 x float> zeroinitializer, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
252 define float @fold_fadd_nsz_nnan_x_0_ebstrict(float %a) #0 {
253 ; CHECK-LABEL: @fold_fadd_nsz_nnan_x_0_ebstrict(
254 ; CHECK-NEXT: [[ADD:%.*]] = call nnan nsz float @llvm.experimental.constrained.fadd.f32(float [[A:%.*]], float 0.000000e+00, metadata !"round.tonearest", metadata !"fpexcept.strict") #[[ATTR0]]
255 ; CHECK-NEXT: ret float [[ADD]]
257 %add = call nsz nnan float @llvm.experimental.constrained.fadd.f32(float %a, float 0.0, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
261 define <2 x float> @fold_fadd_vec_nsz_nnan_x_0_ebstrict(<2 x float> %a) #0 {
262 ; CHECK-LABEL: @fold_fadd_vec_nsz_nnan_x_0_ebstrict(
263 ; CHECK-NEXT: [[ADD:%.*]] = call nnan nsz <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> [[A:%.*]], <2 x float> zeroinitializer, metadata !"round.tonearest", metadata !"fpexcept.strict") #[[ATTR0]]
264 ; CHECK-NEXT: ret <2 x float> [[ADD]]
266 %add = call nsz nnan <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> %a, <2 x float> zeroinitializer, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
270 define float @fold_fadd_nsz_0_x_defaultenv(float %a) #0 {
271 ; CHECK-LABEL: @fold_fadd_nsz_0_x_defaultenv(
272 ; CHECK-NEXT: ret float [[A:%.*]]
274 %add = call nsz float @llvm.experimental.constrained.fadd.f32(float 0.0, float %a, metadata !"round.tonearest", metadata !"fpexcept.ignore") #0
278 define <2 x float> @fold_fadd_vec_nsz_0_x_defaultenv(<2 x float> %a) #0 {
279 ; CHECK-LABEL: @fold_fadd_vec_nsz_0_x_defaultenv(
280 ; CHECK-NEXT: ret <2 x float> [[A:%.*]]
282 %add = call nsz <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> zeroinitializer, <2 x float> %a, metadata !"round.tonearest", metadata !"fpexcept.ignore") #0
286 ; TODO: Canonicalize the order of the arguments. Then this will fire.
287 define float @fold_fadd_nsz_0_x_ebmaytrap(float %a) #0 {
288 ; CHECK-LABEL: @fold_fadd_nsz_0_x_ebmaytrap(
289 ; CHECK-NEXT: [[ADD:%.*]] = call nsz float @llvm.experimental.constrained.fadd.f32(float 0.000000e+00, float [[A:%.*]], metadata !"round.tonearest", metadata !"fpexcept.maytrap") #[[ATTR0]]
290 ; CHECK-NEXT: ret float [[ADD]]
292 %add = call nsz float @llvm.experimental.constrained.fadd.f32(float 0.0, float %a, metadata !"round.tonearest", metadata !"fpexcept.maytrap") #0
296 ; TODO: Canonicalize the order of the arguments. Then this will fire.
297 define <2 x float> @fold_fadd_vec_nsz_0_x_ebmaytrap(<2 x float> %a) #0 {
298 ; CHECK-LABEL: @fold_fadd_vec_nsz_0_x_ebmaytrap(
299 ; CHECK-NEXT: [[ADD:%.*]] = call nsz <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> zeroinitializer, <2 x float> [[A:%.*]], metadata !"round.tonearest", metadata !"fpexcept.maytrap") #[[ATTR0]]
300 ; CHECK-NEXT: ret <2 x float> [[ADD]]
302 %add = call nsz <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> zeroinitializer, <2 x float> %a, metadata !"round.tonearest", metadata !"fpexcept.maytrap") #0
310 define float @fold_fadd_qnan_qnan_ebmaytrap() #0 {
311 ; CHECK-LABEL: @fold_fadd_qnan_qnan_ebmaytrap(
312 ; CHECK-NEXT: ret float 0x7FF8000000000000
314 %add = call float @llvm.experimental.constrained.fadd.f32(float 0x7ff8000000000000, float 0x7ff8000000000000, metadata !"round.tonearest", metadata !"fpexcept.maytrap") #0
318 define float @fold_fadd_qnan_qnan_ebstrict() #0 {
319 ; CHECK-LABEL: @fold_fadd_qnan_qnan_ebstrict(
320 ; CHECK-NEXT: ret float 0x7FF8000000000000
322 %add = call float @llvm.experimental.constrained.fadd.f32(float 0x7ff8000000000000, float 0x7ff8000000000000, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
326 define float @fold_fadd_snan_qnan_ebmaytrap() #0 {
327 ; CHECK-LABEL: @fold_fadd_snan_qnan_ebmaytrap(
328 ; CHECK-NEXT: ret float 0x7FFC000000000000
330 %add = call float @llvm.experimental.constrained.fadd.f32(float 0x7ff4000000000000, float 0x7ff8000000000000, metadata !"round.tonearest", metadata !"fpexcept.maytrap") #0
334 define float @fold_fadd_snan_qnan_ebstrict() #0 {
335 ; CHECK-LABEL: @fold_fadd_snan_qnan_ebstrict(
336 ; CHECK-NEXT: [[ADD:%.*]] = call float @llvm.experimental.constrained.fadd.f32(float 0x7FF4000000000000, float 0x7FF8000000000000, metadata !"round.tonearest", metadata !"fpexcept.strict") #[[ATTR0]]
337 ; CHECK-NEXT: ret float [[ADD]]
339 %add = call float @llvm.experimental.constrained.fadd.f32(float 0x7ff4000000000000, float 0x7ff8000000000000, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
343 declare float @llvm.experimental.constrained.fadd.f32(float, float, metadata, metadata) #0
344 declare <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float>, <2 x float>, metadata, metadata) #0
346 attributes #0 = { strictfp }