1 ; RUN: opt < %s -passes=libcalls-shrinkwrap -S | FileCheck %s
9 ; d = __builtin_nan ("");
10 ; feclearexcept (FE_ALL_EXCEPT);
12 ; if (fetestexcept (FE_ALL_EXCEPT)) // expect no fp exception raised
16 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
17 target triple = "x86_64-unknown-linux-gnu"
19 define void @test_quiet_nan() {
20 %1 = alloca double, align 8
21 store volatile double 0x7FF8000000000000, ptr %1, align 8
22 %2 = tail call i32 @feclearexcept(i32 noundef 61)
23 %3 = load volatile double, ptr %1, align 8
24 %4 = call double @acos(double noundef %3)
25 ; CHECK: [[COND1:%[0-9]+]] = fcmp ogt double [[VALUE:%.*]], 1.000000e+00
26 ; CHECK: [[COND1:%[0-9]+]] = fcmp olt double [[VALUE]], -1.000000e+00
27 %5 = call i32 @fetestexcept(i32 noundef 61)
28 %6 = icmp ne i32 %5, 0
29 br i1 %6, label %abort, label %ret
39 define void @test_quiet_nan_strictfp() strictfp {
40 %1 = alloca double, align 8
41 store volatile double 0x7FF8000000000000, ptr %1, align 8
42 %2 = tail call i32 @feclearexcept(i32 noundef 61) strictfp
43 %3 = load volatile double, ptr %1, align 8
44 %4 = call double @acos(double noundef %3) strictfp
45 ; Generate constrained fcmp if function has strictfp attribute.
46 ; That avoids raising fp exception with quiet nan input.
47 ; CHECK: [[COND1:%[0-9]+]] = call i1 @llvm.experimental.constrained.fcmp.f64(double [[VALUE]], double 1.000000e+00, metadata !"ogt", metadata !"fpexcept.strict")
48 ; CHECK: [[COND1:%[0-9]+]] = call i1 @llvm.experimental.constrained.fcmp.f64(double [[VALUE]], double -1.000000e+00, metadata !"olt", metadata !"fpexcept.strict")
49 %5 = call i32 @fetestexcept(i32 noundef 61) strictfp
50 %6 = icmp ne i32 %5, 0
51 br i1 %6, label %abort, label %ret
54 call void @abort() strictfp
61 declare i32 @feclearexcept(i32 noundef)
63 declare i32 @fetestexcept(i32 noundef)
65 declare double @acos(double noundef)