1 ; RUN: opt -O3 -S < %s | FileCheck %s
3 ; Test to verify that constants aren't folded when the rounding mode is unknown.
5 ; CHECK: call double @llvm.experimental.constrained.fdiv.f64
6 define double @f1() #0 {
8 %div = call double @llvm.experimental.constrained.fdiv.f64(
11 metadata !"round.dynamic",
12 metadata !"fpexcept.strict") #0
16 ; Verify that 'a - 0' isn't simplified to 'a' when the rounding mode is unknown.
18 ; double f2(double a) {
19 ; // Because the result of '0 - 0' is negative zero if rounding mode is
20 ; // downward, this shouldn't be simplified.
25 ; CHECK: call double @llvm.experimental.constrained.fsub.f64
26 define double @f2(double %a) #0 {
28 %div = call double @llvm.experimental.constrained.fsub.f64(
29 double %a, double 0.000000e+00,
30 metadata !"round.dynamic",
31 metadata !"fpexcept.strict") #0
35 ; Verify that '-((-a)*b)' isn't simplified to 'a*b' when the rounding mode is
38 ; double f3(double a, double b) {
39 ; // Because the intermediate value involved in this calculation may require
40 ; // rounding, this shouldn't be simplified.
45 ; CHECK: call double @llvm.experimental.constrained.fsub.f64
46 ; CHECK: call double @llvm.experimental.constrained.fmul.f64
47 ; CHECK: call double @llvm.experimental.constrained.fsub.f64
48 define double @f3(double %a, double %b) #0 {
50 %sub = call double @llvm.experimental.constrained.fsub.f64(
51 double -0.000000e+00, double %a,
52 metadata !"round.dynamic",
53 metadata !"fpexcept.strict") #0
54 %mul = call double @llvm.experimental.constrained.fmul.f64(
55 double %sub, double %b,
56 metadata !"round.dynamic",
57 metadata !"fpexcept.strict") #0
58 %ret = call double @llvm.experimental.constrained.fsub.f64(
61 metadata !"round.dynamic",
62 metadata !"fpexcept.strict") #0
66 ; Verify that FP operations are not performed speculatively when FP exceptions
67 ; are not being ignored.
69 ; double f4(int n, double a) {
70 ; // Because a + 1 may overflow, this should not be simplified.
80 define double @f4(i32 %n, double %a) #0 {
82 %cmp = icmp sgt i32 %n, 0
83 br i1 %cmp, label %if.then, label %if.end
86 %add = call double @llvm.experimental.constrained.fadd.f64(
87 double 1.000000e+00, double %a,
88 metadata !"round.dynamic",
89 metadata !"fpexcept.strict") #0
93 %a.0 = phi double [%add, %if.then], [ %a, %entry ]
97 ; Verify that sqrt(42.0) isn't simplified when the rounding mode is unknown.
99 ; CHECK: call double @llvm.experimental.constrained.sqrt
100 define double @f5() #0 {
102 %result = call double @llvm.experimental.constrained.sqrt.f64(double 42.0,
103 metadata !"round.dynamic",
104 metadata !"fpexcept.strict") #0
108 ; Verify that pow(42.1, 3.0) isn't simplified when the rounding mode is unknown.
110 ; CHECK: call double @llvm.experimental.constrained.pow
111 define double @f6() #0 {
113 %result = call double @llvm.experimental.constrained.pow.f64(double 42.1,
115 metadata !"round.dynamic",
116 metadata !"fpexcept.strict") #0
120 ; Verify that powi(42.1, 3) isn't simplified when the rounding mode is unknown.
122 ; CHECK: call double @llvm.experimental.constrained.powi
123 define double @f7() #0 {
125 %result = call double @llvm.experimental.constrained.powi.f64(double 42.1,
127 metadata !"round.dynamic",
128 metadata !"fpexcept.strict") #0
132 ; Verify that sin(42.0) isn't simplified when the rounding mode is unknown.
134 ; CHECK: call double @llvm.experimental.constrained.sin
135 define double @f8() #0 {
137 %result = call double @llvm.experimental.constrained.sin.f64(double 42.0,
138 metadata !"round.dynamic",
139 metadata !"fpexcept.strict") #0
143 ; Verify that cos(42.0) isn't simplified when the rounding mode is unknown.
145 ; CHECK: call double @llvm.experimental.constrained.cos
146 define double @f9() #0 {
148 %result = call double @llvm.experimental.constrained.cos.f64(double 42.0,
149 metadata !"round.dynamic",
150 metadata !"fpexcept.strict") #0
154 ; Verify that tan(42.0) isn't simplified when the rounding mode is unknown.
156 ; CHECK: call double @llvm.experimental.constrained.tan
157 define double @ftan() #0 {
159 %result = call double @llvm.experimental.constrained.tan.f64(double 42.0,
160 metadata !"round.dynamic",
161 metadata !"fpexcept.strict") #0
165 ; Verify that acos(42.0) isn't simplified when the rounding mode is unknown.
167 ; CHECK: call double @llvm.experimental.constrained.acos
168 define double @facos() #0 {
170 %result = call double @llvm.experimental.constrained.acos.f64(double 42.0,
171 metadata !"round.dynamic",
172 metadata !"fpexcept.strict") #0
176 ; Verify that asin(42.0) isn't simplified when the rounding mode is unknown.
178 ; CHECK: call double @llvm.experimental.constrained.asin
179 define double @fasin() #0 {
181 %result = call double @llvm.experimental.constrained.asin.f64(double 42.0,
182 metadata !"round.dynamic",
183 metadata !"fpexcept.strict") #0
187 ; Verify that atan(42.0) isn't simplified when the rounding mode is unknown.
189 ; CHECK: call double @llvm.experimental.constrained.atan
190 define double @fatan() #0 {
192 %result = call double @llvm.experimental.constrained.atan.f64(double 42.0,
193 metadata !"round.dynamic",
194 metadata !"fpexcept.strict") #0
198 ; Verify that cosh(42.0) isn't simplified when the rounding mode is unknown.
200 ; CHECK: call double @llvm.experimental.constrained.cosh
201 define double @fcosh() #0 {
203 %result = call double @llvm.experimental.constrained.cosh.f64(double 42.0,
204 metadata !"round.dynamic",
205 metadata !"fpexcept.strict") #0
209 ; Verify that sinh(42.0) isn't simplified when the rounding mode is unknown.
211 ; CHECK: call double @llvm.experimental.constrained.sinh
212 define double @fsinh() #0 {
214 %result = call double @llvm.experimental.constrained.sinh.f64(double 42.0,
215 metadata !"round.dynamic",
216 metadata !"fpexcept.strict") #0
220 ; Verify that tanh(42.0) isn't simplified when the rounding mode is unknown.
222 ; CHECK: call double @llvm.experimental.constrained.tanh
223 define double @ftanh() #0 {
225 %result = call double @llvm.experimental.constrained.tanh.f64(double 42.0,
226 metadata !"round.dynamic",
227 metadata !"fpexcept.strict") #0
231 ; Verify that exp(42.0) isn't simplified when the rounding mode is unknown.
233 ; CHECK: call double @llvm.experimental.constrained.exp
234 define double @f10() #0 {
236 %result = call double @llvm.experimental.constrained.exp.f64(double 42.0,
237 metadata !"round.dynamic",
238 metadata !"fpexcept.strict") #0
242 ; Verify that exp2(42.1) isn't simplified when the rounding mode is unknown.
244 ; CHECK: call double @llvm.experimental.constrained.exp2
245 define double @f11() #0 {
247 %result = call double @llvm.experimental.constrained.exp2.f64(double 42.1,
248 metadata !"round.dynamic",
249 metadata !"fpexcept.strict") #0
253 ; Verify that log(42.0) isn't simplified when the rounding mode is unknown.
255 ; CHECK: call double @llvm.experimental.constrained.log
256 define double @f12() #0 {
258 %result = call double @llvm.experimental.constrained.log.f64(double 42.0,
259 metadata !"round.dynamic",
260 metadata !"fpexcept.strict") #0
264 ; Verify that log10(42.0) isn't simplified when the rounding mode is unknown.
266 ; CHECK: call double @llvm.experimental.constrained.log10
267 define double @f13() #0 {
269 %result = call double @llvm.experimental.constrained.log10.f64(double 42.0,
270 metadata !"round.dynamic",
271 metadata !"fpexcept.strict") #0
275 ; Verify that log2(42.0) isn't simplified when the rounding mode is unknown.
277 ; CHECK: call double @llvm.experimental.constrained.log2
278 define double @f14() #0 {
280 %result = call double @llvm.experimental.constrained.log2.f64(double 42.0,
281 metadata !"round.dynamic",
282 metadata !"fpexcept.strict") #0
286 ; Verify that rint(42.1) isn't simplified when the rounding mode is unknown.
288 ; CHECK: call double @llvm.experimental.constrained.rint
289 define double @f15() #0 {
291 %result = call double @llvm.experimental.constrained.rint.f64(double 42.1,
292 metadata !"round.dynamic",
293 metadata !"fpexcept.strict") #0
297 ; Verify that nearbyint(42.1) isn't simplified when the rounding mode is
300 ; CHECK: call double @llvm.experimental.constrained.nearbyint
301 define double @f16() #0 {
303 %result = call double @llvm.experimental.constrained.nearbyint.f64(
305 metadata !"round.dynamic",
306 metadata !"fpexcept.strict") #0
310 ; Verify that fma(42.1) isn't simplified when the rounding mode is
313 ; CHECK: call double @llvm.experimental.constrained.fma
314 define double @f17() #0 {
316 %result = call double @llvm.experimental.constrained.fma.f64(double 42.1, double 42.1, double 42.1,
317 metadata !"round.dynamic",
318 metadata !"fpexcept.strict") #0
322 ; Verify that fptoui(42.1) isn't simplified when the rounding mode is
325 ; CHECK: call zeroext i32 @llvm.experimental.constrained.fptoui
326 define zeroext i32 @f18() #0 {
328 %result = call zeroext i32 @llvm.experimental.constrained.fptoui.i32.f64(
330 metadata !"fpexcept.strict") #0
334 ; Verify that fptosi(42.1) isn't simplified when the rounding mode is
337 ; CHECK: call i32 @llvm.experimental.constrained.fptosi
338 define i32 @f19() #0 {
340 %result = call i32 @llvm.experimental.constrained.fptosi.i32.f64(double 42.1,
341 metadata !"fpexcept.strict") #0
345 ; Verify that fptrunc(42.1) isn't simplified when the rounding mode is
348 ; CHECK: call float @llvm.experimental.constrained.fptrunc
349 define float @f20() #0 {
351 %result = call float @llvm.experimental.constrained.fptrunc.f32.f64(
353 metadata !"round.dynamic",
354 metadata !"fpexcept.strict") #0
358 ; Verify that fpext(42.1) isn't simplified when the rounding mode is
361 ; CHECK: call double @llvm.experimental.constrained.fpext
362 define double @f21() #0 {
364 %result = call double @llvm.experimental.constrained.fpext.f64.f32(float 42.0,
365 metadata !"fpexcept.strict") #0
369 ; Verify that lrint(42.1) isn't simplified when the rounding mode is unknown.
371 ; CHECK: call i32 @llvm.experimental.constrained.lrint
372 define i32 @f22() #0 {
374 %result = call i32 @llvm.experimental.constrained.lrint.i32.f64(double 42.1,
375 metadata !"round.dynamic",
376 metadata !"fpexcept.strict") #0
380 ; Verify that lrintf(42.0) isn't simplified when the rounding mode is unknown.
382 ; CHECK: call i32 @llvm.experimental.constrained.lrint
383 define i32 @f23() #0 {
385 %result = call i32 @llvm.experimental.constrained.lrint.i32.f32(float 42.0,
386 metadata !"round.dynamic",
387 metadata !"fpexcept.strict") #0
391 ; Verify that llrint(42.1) isn't simplified when the rounding mode is unknown.
393 ; CHECK: call i64 @llvm.experimental.constrained.llrint
394 define i64 @f24() #0 {
396 %result = call i64 @llvm.experimental.constrained.llrint.i64.f64(double 42.1,
397 metadata !"round.dynamic",
398 metadata !"fpexcept.strict") #0
402 ; Verify that llrint(42.0) isn't simplified when the rounding mode is unknown.
404 ; CHECK: call i64 @llvm.experimental.constrained.llrint
405 define i64 @f25() #0 {
407 %result = call i64 @llvm.experimental.constrained.llrint.i64.f32(float 42.0,
408 metadata !"round.dynamic",
409 metadata !"fpexcept.strict") #0
413 ; Verify that lround(42.1) isn't simplified when the rounding mode is unknown.
415 ; CHECK: call i32 @llvm.experimental.constrained.lround
416 define i32 @f26() #0 {
418 %result = call i32 @llvm.experimental.constrained.lround.i32.f64(double 42.1,
419 metadata !"fpexcept.strict") #0
423 ; Verify that lround(42.0) isn't simplified when the rounding mode is unknown.
425 ; CHECK: call i32 @llvm.experimental.constrained.lround
426 define i32 @f27() #0 {
428 %result = call i32 @llvm.experimental.constrained.lround.i32.f32(float 42.0,
429 metadata !"fpexcept.strict") #0
433 ; Verify that llround(42.1) isn't simplified when the rounding mode is unknown.
435 ; CHECK: call i64 @llvm.experimental.constrained.llround
436 define i64 @f28() #0 {
438 %result = call i64 @llvm.experimental.constrained.llround.i64.f64(double 42.1,
439 metadata !"fpexcept.strict") #0
443 ; Verify that llround(42.0) isn't simplified when the rounding mode is unknown.
445 ; CHECK: call i64 @llvm.experimental.constrained.llround
446 define i64 @f29() #0 {
448 %result = call i64 @llvm.experimental.constrained.llround.i64.f32(float 42.0,
449 metadata !"fpexcept.strict") #0
453 ; Verify that sitofp(42) isn't simplified when the rounding mode is unknown.
455 ; CHECK: call double @llvm.experimental.constrained.sitofp
456 define double @f30() #0 {
458 %result = call double @llvm.experimental.constrained.sitofp.f64.i32(i32 42,
459 metadata !"round.dynamic",
460 metadata !"fpexcept.strict") #0
464 ; Verify that uitofp(42) isn't simplified when the rounding mode is unknown.
466 ; CHECK: call double @llvm.experimental.constrained.uitofp
467 define double @f31() #0 {
469 %result = call double @llvm.experimental.constrained.uitofp.f64.i32(i32 42,
470 metadata !"round.dynamic",
471 metadata !"fpexcept.strict") #0
475 attributes #0 = { strictfp }
477 @llvm.fp.env = thread_local global i8 zeroinitializer, section "llvm.metadata"
478 declare double @llvm.experimental.constrained.fdiv.f64(double, double, metadata, metadata)
479 declare double @llvm.experimental.constrained.fmul.f64(double, double, metadata, metadata)
480 declare double @llvm.experimental.constrained.fadd.f64(double, double, metadata, metadata)
481 declare double @llvm.experimental.constrained.fsub.f64(double, double, metadata, metadata)
482 declare double @llvm.experimental.constrained.sqrt.f64(double, metadata, metadata)
483 declare double @llvm.experimental.constrained.pow.f64(double, double, metadata, metadata)
484 declare double @llvm.experimental.constrained.powi.f64(double, i32, metadata, metadata)
485 declare double @llvm.experimental.constrained.sin.f64(double, metadata, metadata)
486 declare double @llvm.experimental.constrained.cos.f64(double, metadata, metadata)
487 declare double @llvm.experimental.constrained.tan.f64(double, metadata, metadata)
488 declare double @llvm.experimental.constrained.exp.f64(double, metadata, metadata)
489 declare double @llvm.experimental.constrained.exp2.f64(double, metadata, metadata)
490 declare double @llvm.experimental.constrained.log.f64(double, metadata, metadata)
491 declare double @llvm.experimental.constrained.log10.f64(double, metadata, metadata)
492 declare double @llvm.experimental.constrained.log2.f64(double, metadata, metadata)
493 declare double @llvm.experimental.constrained.rint.f64(double, metadata, metadata)
494 declare double @llvm.experimental.constrained.nearbyint.f64(double, metadata, metadata)
495 declare double @llvm.experimental.constrained.fma.f64(double, double, double, metadata, metadata)
496 declare i32 @llvm.experimental.constrained.fptosi.i32.f64(double, metadata)
497 declare i32 @llvm.experimental.constrained.fptoui.i32.f64(double, metadata)
498 declare float @llvm.experimental.constrained.fptrunc.f32.f64(double, metadata, metadata)
499 declare double @llvm.experimental.constrained.fpext.f64.f32(float, metadata)
500 declare i32 @llvm.experimental.constrained.lrint.i32.f64(double, metadata, metadata)
501 declare i32 @llvm.experimental.constrained.lrint.i32.f32(float, metadata, metadata)
502 declare i64 @llvm.experimental.constrained.llrint.i64.f64(double, metadata, metadata)
503 declare i64 @llvm.experimental.constrained.llrint.i64.f32(float, metadata, metadata)
504 declare i32 @llvm.experimental.constrained.lround.i32.f64(double, metadata)
505 declare i32 @llvm.experimental.constrained.lround.i32.f32(float, metadata)
506 declare i64 @llvm.experimental.constrained.llround.i64.f64(double, metadata)
507 declare i64 @llvm.experimental.constrained.llround.i64.f32(float, metadata)
508 declare double @llvm.experimental.constrained.sitofp.f64.i32(i32, metadata, metadata)
509 declare double @llvm.experimental.constrained.uitofp.f64.i32(i32, metadata, metadata)