1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=instsimplify < %s | FileCheck %s
4 define float @ldexp_f32_undef_undef() {
5 ; CHECK-LABEL: @ldexp_f32_undef_undef(
6 ; CHECK-NEXT: ret float 0x7FF8000000000000
8 %call = call float @llvm.ldexp.f32.i32(float undef, i32 undef)
12 define float @ldexp_f32_poison_undef() {
13 ; CHECK-LABEL: @ldexp_f32_poison_undef(
14 ; CHECK-NEXT: ret float poison
16 %call = call float @llvm.ldexp.f32.i32(float poison, i32 undef)
20 define float @ldexp_f32_undef_poison() {
21 ; CHECK-LABEL: @ldexp_f32_undef_poison(
22 ; CHECK-NEXT: ret float undef
24 %call = call float @llvm.ldexp.f32.i32(float undef, i32 poison)
28 define float @ldexp_f32_poison_poison() {
29 ; CHECK-LABEL: @ldexp_f32_poison_poison(
30 ; CHECK-NEXT: ret float poison
32 %call = call float @llvm.ldexp.f32.i32(float poison, i32 poison)
36 ; If the exponent is 0, it doesn't matter if the first argument is
38 define void @ldexp_f32_exp0(float %x) {
39 ; CHECK-LABEL: @ldexp_f32_exp0(
40 ; CHECK-NEXT: store volatile float [[X:%.*]], ptr addrspace(1) undef, align 4
41 ; CHECK-NEXT: store volatile float [[X]], ptr addrspace(1) undef, align 4
42 ; CHECK-NEXT: [[ONE:%.*]] = call float @llvm.ldexp.f32.i32(float [[X]], i32 1)
43 ; CHECK-NEXT: store volatile float [[ONE]], ptr addrspace(1) undef, align 4
44 ; CHECK-NEXT: ret void
46 %zero = call float @llvm.ldexp.f32.i32(float %x, i32 0)
47 store volatile float %zero, ptr addrspace(1) undef
49 %undef = call float @llvm.ldexp.f32.i32(float %x, i32 undef)
50 store volatile float %undef, ptr addrspace(1) undef
52 %one = call float @llvm.ldexp.f32.i32(float %x, i32 1)
53 store volatile float %one, ptr addrspace(1) undef
57 define void @ldexp_v2f32_exp0(<2 x float> %x) {
58 ; CHECK-LABEL: @ldexp_v2f32_exp0(
59 ; CHECK-NEXT: store volatile <2 x float> [[X:%.*]], ptr addrspace(1) undef, align 8
60 ; CHECK-NEXT: store volatile <2 x float> [[X]], ptr addrspace(1) undef, align 8
61 ; CHECK-NEXT: store volatile <2 x float> [[X]], ptr addrspace(1) undef, align 8
62 ; CHECK-NEXT: ret void
64 %part.undef0 = call <2 x float> @llvm.ldexp.v2f32.v2i32(<2 x float> %x, <2 x i32> <i32 0, i32 undef>)
65 store volatile <2 x float> %part.undef0, ptr addrspace(1) undef
67 %part.undef1 = call <2 x float> @llvm.ldexp.v2f32.v2i32(<2 x float> %x, <2 x i32> <i32 undef, i32 0>)
68 store volatile <2 x float> %part.undef1, ptr addrspace(1) undef
70 %zero = call <2 x float> @llvm.ldexp.v2f32.v2i32(<2 x float> %x, <2 x i32> zeroinitializer)
71 store volatile <2 x float> %zero, ptr addrspace(1) undef
75 ; Test variable exponent but zero or undef value.
76 define void @ldexp_f32_val0(i32 %y) {
77 ; CHECK-LABEL: @ldexp_f32_val0(
78 ; CHECK-NEXT: store volatile float 0.000000e+00, ptr addrspace(1) undef, align 4
79 ; CHECK-NEXT: store volatile float -0.000000e+00, ptr addrspace(1) undef, align 4
80 ; CHECK-NEXT: store volatile float 0x7FF8000000000000, ptr addrspace(1) undef, align 4
81 ; CHECK-NEXT: ret void
83 %zero = call float @llvm.ldexp.f32.i32(float 0.0, i32 %y)
84 store volatile float %zero, ptr addrspace(1) undef
86 %neg.zero = call float @llvm.ldexp.f32.i32(float -0.0, i32 %y)
87 store volatile float %neg.zero, ptr addrspace(1) undef
89 %undef = call float @llvm.ldexp.f32.i32(float undef, i32 %y)
90 store volatile float %undef, ptr addrspace(1) undef
94 define void @ldexp_f32_val_infinity(i32 %y) {
95 ; CHECK-LABEL: @ldexp_f32_val_infinity(
96 ; CHECK-NEXT: store volatile float 0x7FF0000000000000, ptr addrspace(1) undef, align 4
97 ; CHECK-NEXT: store volatile float 0xFFF0000000000000, ptr addrspace(1) undef, align 4
98 ; CHECK-NEXT: store volatile float 0x7FF0000000000000, ptr addrspace(1) undef, align 4
99 ; CHECK-NEXT: store volatile float 0xFFF0000000000000, ptr addrspace(1) undef, align 4
100 ; CHECK-NEXT: ret void
102 %inf = call float @llvm.ldexp.f32.i32(float 0x7ff0000000000000, i32 %y)
103 store volatile float %inf, ptr addrspace(1) undef
105 %neg.inf = call float @llvm.ldexp.f32.i32(float 0xfff0000000000000, i32 %y)
106 store volatile float %neg.inf, ptr addrspace(1) undef
108 %inf.zero = call float @llvm.ldexp.f32.i32(float 0x7ff0000000000000, i32 0)
109 store volatile float %inf.zero, ptr addrspace(1) undef
111 %neg.inf.zero = call float @llvm.ldexp.f32.i32(float 0xfff0000000000000, i32 0)
112 store volatile float %neg.inf.zero, ptr addrspace(1) undef
117 ; Signaling nan should be quieted.
118 ; Technically this depends on the ieee_mode in the mode register.
119 define void @ldexp_f32_val_nan(i32 %y) {
120 ; CHECK-LABEL: @ldexp_f32_val_nan(
121 ; CHECK-NEXT: store volatile float 0x7FF8001000000000, ptr addrspace(1) undef, align 4
122 ; CHECK-NEXT: store volatile float 0xFFF8000100000000, ptr addrspace(1) undef, align 4
123 ; CHECK-NEXT: store volatile float 0x7FF8000020000000, ptr addrspace(1) undef, align 4
124 ; CHECK-NEXT: store volatile float 0xFFFFFFFFE0000000, ptr addrspace(1) undef, align 4
125 ; CHECK-NEXT: ret void
127 %plus.qnan = call float @llvm.ldexp.f32.i32(float 0x7ff0001000000000, i32 %y)
128 store volatile float %plus.qnan, ptr addrspace(1) undef
130 %neg.qnan = call float @llvm.ldexp.f32.i32(float 0xfff0000100000000, i32 %y)
131 store volatile float %neg.qnan, ptr addrspace(1) undef
133 %plus.snan = call float @llvm.ldexp.f32.i32(float 0x7FF0000020000000, i32 %y)
134 store volatile float %plus.snan, ptr addrspace(1) undef
136 %neg.snan = call float @llvm.ldexp.f32.i32(float 0xFFF7FFFFE0000000, i32 %y)
137 store volatile float %neg.snan, ptr addrspace(1) undef
142 define void @ldexp_f32_val_nan_strictfp_maytrap(i32 %y) #0 {
143 ; CHECK-LABEL: @ldexp_f32_val_nan_strictfp_maytrap(
144 ; CHECK-NEXT: [[PLUS_QNAN:%.*]] = call float @llvm.experimental.constrained.ldexp.f32.i32(float 0x7FF0001000000000, i32 [[Y:%.*]], metadata !"round.dynamic", metadata !"fpexcept.maytrap") #[[ATTR0:[0-9]+]]
145 ; CHECK-NEXT: store volatile float [[PLUS_QNAN]], ptr addrspace(1) undef, align 4
146 ; CHECK-NEXT: [[NEG_QNAN:%.*]] = call float @llvm.experimental.constrained.ldexp.f32.i32(float 0xFFF0000100000000, i32 [[Y]], metadata !"round.dynamic", metadata !"fpexcept.maytrap") #[[ATTR0]]
147 ; CHECK-NEXT: store volatile float [[NEG_QNAN]], ptr addrspace(1) undef, align 4
148 ; CHECK-NEXT: [[PLUS_SNAN:%.*]] = call float @llvm.experimental.constrained.ldexp.f32.i32(float 0x7FF0000020000000, i32 [[Y]], metadata !"round.dynamic", metadata !"fpexcept.maytrap") #[[ATTR0]]
149 ; CHECK-NEXT: store volatile float [[PLUS_SNAN]], ptr addrspace(1) undef, align 4
150 ; CHECK-NEXT: [[NEG_SNAN:%.*]] = call float @llvm.experimental.constrained.ldexp.f32.i32(float 0xFFF7FFFFE0000000, i32 [[Y]], metadata !"round.dynamic", metadata !"fpexcept.maytrap") #[[ATTR0]]
151 ; CHECK-NEXT: store volatile float [[NEG_SNAN]], ptr addrspace(1) undef, align 4
152 ; CHECK-NEXT: store volatile float 0x7FF8000000000000, ptr addrspace(1) undef, align 4
153 ; CHECK-NEXT: ret void
155 %plus.qnan = call float @llvm.experimental.constrained.ldexp.f32.i32(float 0x7ff0001000000000, i32 %y, metadata !"round.dynamic", metadata !"fpexcept.maytrap") #0
156 store volatile float %plus.qnan, ptr addrspace(1) undef
158 %neg.qnan = call float @llvm.experimental.constrained.ldexp.f32.i32(float 0xfff0000100000000, i32 %y, metadata !"round.dynamic", metadata !"fpexcept.maytrap") #0
159 store volatile float %neg.qnan, ptr addrspace(1) undef
161 %plus.snan = call float @llvm.experimental.constrained.ldexp.f32.i32(float 0x7FF0000020000000, i32 %y, metadata !"round.dynamic", metadata !"fpexcept.maytrap") #0
162 store volatile float %plus.snan, ptr addrspace(1) undef
164 %neg.snan = call float @llvm.experimental.constrained.ldexp.f32.i32(float 0xFFF7FFFFE0000000, i32 %y, metadata !"round.dynamic", metadata !"fpexcept.maytrap") #0
165 store volatile float %neg.snan, ptr addrspace(1) undef
167 %undef = call float @llvm.experimental.constrained.ldexp.f32.i32(float undef, i32 %y, metadata !"round.dynamic", metadata !"fpexcept.maytrap") #0
168 store volatile float %undef, ptr addrspace(1) undef
174 define void @ldexp_f32_val_nan_strictfp_strict(i32 %y) #0 {
175 ; CHECK-LABEL: @ldexp_f32_val_nan_strictfp_strict(
176 ; CHECK-NEXT: [[PLUS_QNAN:%.*]] = call float @llvm.experimental.constrained.ldexp.f32.i32(float 0x7FF0001000000000, i32 [[Y:%.*]], metadata !"round.dynamic", metadata !"fpexcept.strict") #[[ATTR0]]
177 ; CHECK-NEXT: store volatile float [[PLUS_QNAN]], ptr addrspace(1) undef, align 4
178 ; CHECK-NEXT: [[NEG_QNAN:%.*]] = call float @llvm.experimental.constrained.ldexp.f32.i32(float 0xFFF0000100000000, i32 [[Y]], metadata !"round.dynamic", metadata !"fpexcept.strict") #[[ATTR0]]
179 ; CHECK-NEXT: store volatile float [[NEG_QNAN]], ptr addrspace(1) undef, align 4
180 ; CHECK-NEXT: [[PLUS_SNAN:%.*]] = call float @llvm.experimental.constrained.ldexp.f32.i32(float 0x7FF0000020000000, i32 [[Y]], metadata !"round.dynamic", metadata !"fpexcept.strict") #[[ATTR0]]
181 ; CHECK-NEXT: store volatile float [[PLUS_SNAN]], ptr addrspace(1) undef, align 4
182 ; CHECK-NEXT: [[NEG_SNAN:%.*]] = call float @llvm.experimental.constrained.ldexp.f32.i32(float 0xFFF7FFFFE0000000, i32 [[Y]], metadata !"round.dynamic", metadata !"fpexcept.strict") #[[ATTR0]]
183 ; CHECK-NEXT: store volatile float [[NEG_SNAN]], ptr addrspace(1) undef, align 4
184 ; CHECK-NEXT: [[UNDEF:%.*]] = call float @llvm.experimental.constrained.ldexp.f32.i32(float undef, i32 [[Y]], metadata !"round.dynamic", metadata !"fpexcept.strict") #[[ATTR0]]
185 ; CHECK-NEXT: store volatile float 0x7FF8000000000000, ptr addrspace(1) undef, align 4
186 ; CHECK-NEXT: ret void
188 %plus.qnan = call float @llvm.experimental.constrained.ldexp.f32.i32(float 0x7ff0001000000000, i32 %y, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
189 store volatile float %plus.qnan, ptr addrspace(1) undef
191 %neg.qnan = call float @llvm.experimental.constrained.ldexp.f32.i32(float 0xfff0000100000000, i32 %y, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
192 store volatile float %neg.qnan, ptr addrspace(1) undef
194 %plus.snan = call float @llvm.experimental.constrained.ldexp.f32.i32(float 0x7FF0000020000000, i32 %y, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
195 store volatile float %plus.snan, ptr addrspace(1) undef
197 %neg.snan = call float @llvm.experimental.constrained.ldexp.f32.i32(float 0xFFF7FFFFE0000000, i32 %y, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
198 store volatile float %neg.snan, ptr addrspace(1) undef
200 %undef = call float @llvm.experimental.constrained.ldexp.f32.i32(float undef, i32 %y, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
201 store volatile float %undef, ptr addrspace(1) undef
206 define void @ldexp_f32_0() {
207 ; CHECK-LABEL: @ldexp_f32_0(
208 ; CHECK-NEXT: store volatile float 0.000000e+00, ptr addrspace(1) undef, align 4
209 ; CHECK-NEXT: store volatile float -0.000000e+00, ptr addrspace(1) undef, align 4
210 ; CHECK-NEXT: store volatile float 0.000000e+00, ptr addrspace(1) undef, align 4
211 ; CHECK-NEXT: store volatile float 0.000000e+00, ptr addrspace(1) undef, align 4
212 ; CHECK-NEXT: store volatile float 0.000000e+00, ptr addrspace(1) undef, align 4
213 ; CHECK-NEXT: store volatile float 0.000000e+00, ptr addrspace(1) undef, align 4
214 ; CHECK-NEXT: store volatile float 0.000000e+00, ptr addrspace(1) undef, align 4
215 ; CHECK-NEXT: ret void
217 %zero = call float @llvm.ldexp.f32.i32(float 0.0, i32 0)
218 store volatile float %zero, ptr addrspace(1) undef
220 %neg.zero = call float @llvm.ldexp.f32.i32(float -0.0, i32 0)
221 store volatile float %neg.zero, ptr addrspace(1) undef
223 %one = call float @llvm.ldexp.f32.i32(float 0.0, i32 1)
224 store volatile float %one, ptr addrspace(1) undef
226 %min.exp = call float @llvm.ldexp.f32.i32(float 0.0, i32 -126)
227 store volatile float %min.exp, ptr addrspace(1) undef
229 %min.exp.sub1 = call float @llvm.ldexp.f32.i32(float 0.0, i32 -127)
230 store volatile float %min.exp.sub1, ptr addrspace(1) undef
232 %max.exp = call float @llvm.ldexp.f32.i32(float 0.0, i32 127)
233 store volatile float %max.exp, ptr addrspace(1) undef
235 %max.exp.plus1 = call float @llvm.ldexp.f32.i32(float 0.0, i32 128)
236 store volatile float %max.exp.plus1, ptr addrspace(1) undef
241 define void @ldexp_f32_undef_strictfp(float %x, i32 %y) #0 {
242 ; CHECK-LABEL: @ldexp_f32_undef_strictfp(
243 ; CHECK-NEXT: [[UNDEF_EXP:%.*]] = call float @llvm.experimental.constrained.ldexp.f32.i32(float [[X:%.*]], i32 undef, metadata !"round.dynamic", metadata !"fpexcept.maytrap") #[[ATTR0]]
244 ; CHECK-NEXT: store volatile float [[UNDEF_EXP]], ptr addrspace(1) undef, align 4
245 ; CHECK-NEXT: store volatile float [[X]], ptr addrspace(1) undef, align 4
246 ; CHECK-NEXT: store volatile float 0x7FF8000000000000, ptr addrspace(1) undef, align 4
247 ; CHECK-NEXT: store volatile float poison, ptr addrspace(1) undef, align 4
248 ; CHECK-NEXT: store volatile float poison, ptr addrspace(1) undef, align 4
249 ; CHECK-NEXT: store volatile float undef, ptr addrspace(1) undef, align 4
250 ; CHECK-NEXT: ret void
252 %undef.exp = call float @llvm.experimental.constrained.ldexp.f32.i32(float %x, i32 undef, metadata !"round.dynamic", metadata !"fpexcept.maytrap") #0
253 store volatile float %undef.exp, ptr addrspace(1) undef
254 %poison.exp = call float @llvm.experimental.constrained.ldexp.f32.i32(float %x, i32 poison, metadata !"round.dynamic", metadata !"fpexcept.maytrap") #0
255 store volatile float %poison.exp, ptr addrspace(1) undef
256 %undef.val = call float @llvm.experimental.constrained.ldexp.f32.i32(float undef, i32 %y, metadata !"round.dynamic", metadata !"fpexcept.maytrap") #0
257 store volatile float %undef.val, ptr addrspace(1) undef
258 %poison.val = call float @llvm.experimental.constrained.ldexp.f32.i32(float poison, i32 %y, metadata !"round.dynamic", metadata !"fpexcept.maytrap") #0
259 store volatile float %poison.val, ptr addrspace(1) undef
260 %poison.undef = call float @llvm.experimental.constrained.ldexp.f32.i32(float poison, i32 undef, metadata !"round.dynamic", metadata !"fpexcept.maytrap") #0
261 store volatile float %poison.undef, ptr addrspace(1) undef
262 %undef.poison = call float @llvm.experimental.constrained.ldexp.f32.i32(float undef, i32 poison, metadata !"round.dynamic", metadata !"fpexcept.maytrap") #0
263 store volatile float %undef.poison, ptr addrspace(1) undef
267 ; Should be able to ignore strictfp in this case
268 define void @ldexp_f32_0_strictfp(float %x) #0 {
269 ; CHECK-LABEL: @ldexp_f32_0_strictfp(
270 ; CHECK-NEXT: store volatile float 0.000000e+00, ptr addrspace(1) undef, align 4
271 ; CHECK-NEXT: store volatile float -0.000000e+00, ptr addrspace(1) undef, align 4
272 ; CHECK-NEXT: store volatile float 0.000000e+00, ptr addrspace(1) undef, align 4
273 ; CHECK-NEXT: [[UNKNOWN_ZERO:%.*]] = call float @llvm.experimental.constrained.ldexp.f32.i32(float [[X:%.*]], i32 0, metadata !"round.dynamic", metadata !"fpexcept.maytrap") #[[ATTR0]]
274 ; CHECK-NEXT: store volatile float [[UNKNOWN_ZERO]], ptr addrspace(1) undef, align 4
275 ; CHECK-NEXT: [[UNKNOWN_UNDEF:%.*]] = call float @llvm.experimental.constrained.ldexp.f32.i32(float [[X]], i32 undef, metadata !"round.dynamic", metadata !"fpexcept.maytrap") #[[ATTR0]]
276 ; CHECK-NEXT: store volatile float [[UNKNOWN_UNDEF]], ptr addrspace(1) undef, align 4
277 ; CHECK-NEXT: [[DENORMAL_0:%.*]] = call float @llvm.experimental.constrained.ldexp.f32.i32(float 0x380FFFFFC0000000, i32 0, metadata !"round.dynamic", metadata !"fpexcept.maytrap") #[[ATTR0]]
278 ; CHECK-NEXT: store volatile float [[DENORMAL_0]], ptr addrspace(1) undef, align 4
279 ; CHECK-NEXT: [[DENORMAL_1:%.*]] = call float @llvm.experimental.constrained.ldexp.f32.i32(float 0x380FFFFFC0000000, i32 1, metadata !"round.dynamic", metadata !"fpexcept.maytrap") #[[ATTR0]]
280 ; CHECK-NEXT: store volatile float [[DENORMAL_1]], ptr addrspace(1) undef, align 4
281 ; CHECK-NEXT: ret void
283 %zero = call float @llvm.experimental.constrained.ldexp.f32.i32(float 0.0, i32 0, metadata !"round.dynamic", metadata !"fpexcept.maytrap") #0
284 store volatile float %zero, ptr addrspace(1) undef
286 %neg.zero = call float @llvm.experimental.constrained.ldexp.f32.i32(float -0.0, i32 0, metadata !"round.dynamic", metadata !"fpexcept.maytrap") #0
287 store volatile float %neg.zero, ptr addrspace(1) undef
289 %one = call float @llvm.experimental.constrained.ldexp.f32.i32(float 0.0, i32 1, metadata !"round.dynamic", metadata !"fpexcept.maytrap") #0
290 store volatile float %one, ptr addrspace(1) undef
292 %unknown.zero = call float @llvm.experimental.constrained.ldexp.f32.i32(float %x, i32 0, metadata !"round.dynamic", metadata !"fpexcept.maytrap") #0
293 store volatile float %unknown.zero, ptr addrspace(1) undef
295 %unknown.undef = call float @llvm.experimental.constrained.ldexp.f32.i32(float %x, i32 undef, metadata !"round.dynamic", metadata !"fpexcept.maytrap") #0
296 store volatile float %unknown.undef, ptr addrspace(1) undef
298 %denormal.0 = call float @llvm.experimental.constrained.ldexp.f32.i32(float 0x380FFFFFC0000000, i32 0, metadata !"round.dynamic", metadata !"fpexcept.maytrap") #0
299 store volatile float %denormal.0, ptr addrspace(1) undef
301 %denormal.1 = call float @llvm.experimental.constrained.ldexp.f32.i32(float 0x380FFFFFC0000000, i32 1, metadata !"round.dynamic", metadata !"fpexcept.maytrap") #0
302 store volatile float %denormal.1, ptr addrspace(1) undef
307 define void @ldexp_f32() {
308 ; CHECK-LABEL: @ldexp_f32(
309 ; CHECK-NEXT: store volatile float 2.000000e+00, ptr addrspace(1) undef, align 4
310 ; CHECK-NEXT: store volatile float 4.000000e+00, ptr addrspace(1) undef, align 4
311 ; CHECK-NEXT: store volatile float 8.000000e+00, ptr addrspace(1) undef, align 4
312 ; CHECK-NEXT: store volatile float 5.000000e-01, ptr addrspace(1) undef, align 4
313 ; CHECK-NEXT: store volatile float 0x3810000000000000, ptr addrspace(1) undef, align 4
314 ; CHECK-NEXT: store volatile float 0x3800000000000000, ptr addrspace(1) undef, align 4
315 ; CHECK-NEXT: store volatile float 0x47E0000000000000, ptr addrspace(1) undef, align 4
316 ; CHECK-NEXT: store volatile float 0x7FF0000000000000, ptr addrspace(1) undef, align 4
317 ; CHECK-NEXT: store volatile float -2.000000e+00, ptr addrspace(1) undef, align 4
318 ; CHECK-NEXT: store volatile float -4.000000e+00, ptr addrspace(1) undef, align 4
319 ; CHECK-NEXT: store volatile float -8.000000e+00, ptr addrspace(1) undef, align 4
320 ; CHECK-NEXT: store volatile float -5.000000e-01, ptr addrspace(1) undef, align 4
321 ; CHECK-NEXT: store volatile float 0xB810000000000000, ptr addrspace(1) undef, align 4
322 ; CHECK-NEXT: store volatile float 0xB800000000000000, ptr addrspace(1) undef, align 4
323 ; CHECK-NEXT: store volatile float 0xC7E0000000000000, ptr addrspace(1) undef, align 4
324 ; CHECK-NEXT: store volatile float 0xFFF0000000000000, ptr addrspace(1) undef, align 4
325 ; CHECK-NEXT: store volatile float 0x44D5000000000000, ptr addrspace(1) undef, align 4
326 ; CHECK-NEXT: ret void
328 %one.one = call float @llvm.ldexp.f32.i32(float 1.0, i32 1)
329 store volatile float %one.one, ptr addrspace(1) undef
331 %one.two = call float @llvm.ldexp.f32.i32(float 1.0, i32 2)
332 store volatile float %one.two, ptr addrspace(1) undef
334 %one.three = call float @llvm.ldexp.f32.i32(float 1.0, i32 3)
335 store volatile float %one.three, ptr addrspace(1) undef
337 %one.negone = call float @llvm.ldexp.f32.i32(float 1.0, i32 -1)
338 store volatile float %one.negone, ptr addrspace(1) undef
340 %one.min.exp = call float @llvm.ldexp.f32.i32(float 1.0, i32 -126)
341 store volatile float %one.min.exp, ptr addrspace(1) undef
343 %one.min.exp.sub1 = call float @llvm.ldexp.f32.i32(float 1.0, i32 -127)
344 store volatile float %one.min.exp.sub1, ptr addrspace(1) undef
346 %one.max.exp = call float @llvm.ldexp.f32.i32(float 1.0, i32 127)
347 store volatile float %one.max.exp, ptr addrspace(1) undef
349 %one.max.exp.plus1 = call float @llvm.ldexp.f32.i32(float 1.0, i32 128)
350 store volatile float %one.max.exp.plus1, ptr addrspace(1) undef
352 %neg.one.one = call float @llvm.ldexp.f32.i32(float -1.0, i32 1)
353 store volatile float %neg.one.one, ptr addrspace(1) undef
355 %neg.one.two = call float @llvm.ldexp.f32.i32(float -1.0, i32 2)
356 store volatile float %neg.one.two, ptr addrspace(1) undef
358 %neg.one.three = call float @llvm.ldexp.f32.i32(float -1.0, i32 3)
359 store volatile float %neg.one.three, ptr addrspace(1) undef
361 %neg.one.negone = call float @llvm.ldexp.f32.i32(float -1.0, i32 -1)
362 store volatile float %neg.one.negone, ptr addrspace(1) undef
364 %neg.one.min.exp = call float @llvm.ldexp.f32.i32(float -1.0, i32 -126)
365 store volatile float %neg.one.min.exp, ptr addrspace(1) undef
367 %neg.one.min.exp.sub1 = call float @llvm.ldexp.f32.i32(float -1.0, i32 -127)
368 store volatile float %neg.one.min.exp.sub1, ptr addrspace(1) undef
370 %neg.one.max.exp = call float @llvm.ldexp.f32.i32(float -1.0, i32 127)
371 store volatile float %neg.one.max.exp, ptr addrspace(1) undef
373 %neg.one.max.exp.plus1 = call float @llvm.ldexp.f32.i32(float -1.0, i32 128)
374 store volatile float %neg.one.max.exp.plus1, ptr addrspace(1) undef
376 %fortytwo.seven = call float @llvm.ldexp.f32.i32(float 42.0, i32 73)
377 store volatile float %fortytwo.seven, ptr addrspace(1) undef
382 ; Technically we should probably flush these depending on the expected
383 ; denormal mode of the function, but no other IR constant folding
385 define void @ldexp_f32_denormal() {
386 ; CHECK-LABEL: @ldexp_f32_denormal(
387 ; CHECK-NEXT: store volatile float 0x380FFFFFC0000000, ptr addrspace(1) undef, align 4
388 ; CHECK-NEXT: store volatile float 0x381FFFFFC0000000, ptr addrspace(1) undef, align 4
389 ; CHECK-NEXT: ret void
391 %denormal.0 = call float @llvm.ldexp.f32.i32(float 0x380FFFFFC0000000, i32 0)
392 store volatile float %denormal.0, ptr addrspace(1) undef
394 %denormal.1 = call float @llvm.ldexp.f32.i32(float 0x380FFFFFC0000000, i32 1)
395 store volatile float %denormal.1, ptr addrspace(1) undef
400 define void @ldexp_f64() {
401 ; CHECK-LABEL: @ldexp_f64(
402 ; CHECK-NEXT: store volatile double 2.000000e+00, ptr addrspace(1) undef, align 8
403 ; CHECK-NEXT: store volatile double 4.000000e+00, ptr addrspace(1) undef, align 8
404 ; CHECK-NEXT: store volatile double 0x44D5000000000000, ptr addrspace(1) undef, align 8
405 ; CHECK-NEXT: ret void
407 %one.one = call double @llvm.ldexp.f64.i32(double 1.0, i32 1)
408 store volatile double %one.one, ptr addrspace(1) undef
410 %one.two = call double @llvm.ldexp.f64.i32(double 1.0, i32 2)
411 store volatile double %one.two, ptr addrspace(1) undef
413 %fortytwo.seven = call double @llvm.ldexp.f64.i32(double 42.0, i32 73)
414 store volatile double %fortytwo.seven, ptr addrspace(1) undef
419 define void @ldexp_f16() {
420 ; CHECK-LABEL: @ldexp_f16(
421 ; CHECK-NEXT: store volatile half 0xH4000, ptr addrspace(1) undef, align 2
422 ; CHECK-NEXT: store volatile half 0xH4400, ptr addrspace(1) undef, align 2
423 ; CHECK-NEXT: store volatile half 0xH7C00, ptr addrspace(1) undef, align 2
424 ; CHECK-NEXT: ret void
426 %one.one = call half @llvm.ldexp.f16.i32(half 1.0, i32 1)
427 store volatile half %one.one, ptr addrspace(1) undef
429 %one.two = call half @llvm.ldexp.f16.i32(half 1.0, i32 2)
430 store volatile half %one.two, ptr addrspace(1) undef
432 %fortytwo.seven = call half @llvm.ldexp.f16.i32(half 42.0, i32 73)
433 store volatile half %fortytwo.seven, ptr addrspace(1) undef
438 define void @ldexp_ppcf128() {
439 ; CHECK-LABEL: @ldexp_ppcf128(
440 ; CHECK-NEXT: store volatile ppc_fp128 0xMFFF00000000000000000000000000000, ptr addrspace(1) undef, align 16
441 ; CHECK-NEXT: store volatile ppc_fp128 0xMFFFC0000000000000000000000000000, ptr addrspace(1) undef, align 16
442 ; CHECK-NEXT: store volatile ppc_fp128 0xM3FD00000000000000000000000000000, ptr addrspace(1) undef, align 16
443 ; CHECK-NEXT: store volatile ppc_fp128 0xM41700000000000000000000000000000, ptr addrspace(1) undef, align 16
444 ; CHECK-NEXT: store volatile ppc_fp128 0xMC0700000000000000000000000000000, ptr addrspace(1) undef, align 16
445 ; CHECK-NEXT: ret void
447 %neginf = call ppc_fp128 @llvm.ldexp.ppcf128.i32(ppc_fp128 0xMFFF00000000000000000000000000000, i32 0)
448 store volatile ppc_fp128 %neginf, ptr addrspace(1) undef
450 %snan = call ppc_fp128 @llvm.ldexp.ppcf128.i32(ppc_fp128 0xMFFFC0000000000000000000000000000, i32 0)
451 store volatile ppc_fp128 %snan, ptr addrspace(1) undef
453 %one.neg2 = call ppc_fp128 @llvm.ldexp.ppcf128.i32(ppc_fp128 0xM3FF00000000000000000000000000000, i32 -2)
454 store volatile ppc_fp128 %one.neg2, ptr addrspace(1) undef
456 %one.24 = call ppc_fp128 @llvm.ldexp.ppcf128.i32(ppc_fp128 0xM3FF00000000000000000000000000000, i32 24)
457 store volatile ppc_fp128 %one.24, ptr addrspace(1) undef
459 %negone.8 = call ppc_fp128 @llvm.ldexp.ppcf128.i32(ppc_fp128 0xMBFF00000000000000000000000000000, i32 8)
460 store volatile ppc_fp128 %negone.8, ptr addrspace(1) undef
465 define void @constant_fold_ldexp_f32_val_strictfp(i32 %y) #0 {
466 ; CHECK-LABEL: @constant_fold_ldexp_f32_val_strictfp(
467 ; CHECK-NEXT: [[SNAN_MAY_TRAP:%.*]] = call float @llvm.experimental.constrained.ldexp.f32.i32(float 0x7FF0000020000000, i32 3, metadata !"round.tonearest", metadata !"fpexcept.maytrap") #[[ATTR0]]
468 ; CHECK-NEXT: store volatile float [[SNAN_MAY_TRAP]], ptr addrspace(1) undef, align 4
469 ; CHECK-NEXT: [[SNAN_MAY_NOT_TRAP:%.*]] = call float @llvm.experimental.constrained.ldexp.f32.i32(float 0x7FF0000020000000, i32 3, metadata !"round.tonearest", metadata !"fpexcept.ignore") #[[ATTR0]]
470 ; CHECK-NEXT: store volatile float [[SNAN_MAY_NOT_TRAP]], ptr addrspace(1) undef, align 4
471 ; CHECK-NEXT: [[UNKNOWN_ROUNDING:%.*]] = call float @llvm.experimental.constrained.ldexp.f32.i32(float 2.500000e+00, i32 42, metadata !"round.dynamic", metadata !"fpexcept.ignore") #[[ATTR0]]
472 ; CHECK-NEXT: store volatile float [[UNKNOWN_ROUNDING]], ptr addrspace(1) undef, align 4
473 ; CHECK-NEXT: [[NORMAL:%.*]] = call float @llvm.experimental.constrained.ldexp.f32.i32(float 2.500000e+00, i32 42, metadata !"round.tonearest", metadata !"fpexcept.ignore") #[[ATTR0]]
474 ; CHECK-NEXT: store volatile float [[NORMAL]], ptr addrspace(1) undef, align 4
475 ; CHECK-NEXT: [[NORMAL_DOWN:%.*]] = call float @llvm.experimental.constrained.ldexp.f32.i32(float 2.500000e+00, i32 42, metadata !"round.downward", metadata !"fpexcept.ignore") #[[ATTR0]]
476 ; CHECK-NEXT: store volatile float [[NORMAL_DOWN]], ptr addrspace(1) undef, align 4
477 ; CHECK-NEXT: ret void
479 %snan.may.trap = call float @llvm.experimental.constrained.ldexp.f32.i32(float 0x7FF0000020000000, i32 3, metadata !"round.tonearest", metadata !"fpexcept.maytrap") #0
480 store volatile float %snan.may.trap, ptr addrspace(1) undef
482 %snan.may.not.trap = call float @llvm.experimental.constrained.ldexp.f32.i32(float 0x7FF0000020000000, i32 3, metadata !"round.tonearest", metadata !"fpexcept.ignore") #0
483 store volatile float %snan.may.not.trap, ptr addrspace(1) undef
485 %unknown.rounding = call float @llvm.experimental.constrained.ldexp.f32.i32(float 2.5, i32 42, metadata !"round.dynamic", metadata !"fpexcept.ignore") #0
486 store volatile float %unknown.rounding, ptr addrspace(1) undef
488 %normal = call float @llvm.experimental.constrained.ldexp.f32.i32(float 2.5, i32 42, metadata !"round.tonearest", metadata !"fpexcept.ignore") #0
489 store volatile float %normal, ptr addrspace(1) undef
491 %normal.down = call float @llvm.experimental.constrained.ldexp.f32.i32(float 2.5, i32 42, metadata !"round.downward", metadata !"fpexcept.ignore") #0
492 store volatile float %normal.down, ptr addrspace(1) undef
497 declare half @llvm.ldexp.f16.i32(half, i32) #1
498 declare float @llvm.ldexp.f32.i32(float, i32) #1
499 declare double @llvm.ldexp.f64.i32(double, i32) #1
500 declare <2 x float> @llvm.ldexp.v2f32.v2i32(<2 x float>, <2 x i32>) #1
501 declare float @llvm.experimental.constrained.ldexp.f32.i32(float, i32, metadata, metadata) #1
502 declare ppc_fp128 @llvm.ldexp.ppcf128.i32(ppc_fp128, i32) #1
504 attributes #0 = { strictfp }
505 attributes #1 = { nounwind readnone speculatable }