68 lines · plain
1; RUN: opt < %s -passes=libcalls-shrinkwrap -S | FileCheck %s2 3; #include <math.h>4; #include <fenv.h>5; #include <stdlib.h>6;7; void() {8; volatile double d;9; d = __builtin_nan ("");10; feclearexcept (FE_ALL_EXCEPT);11; acos(d);12; if (fetestexcept (FE_ALL_EXCEPT)) // expect no fp exception raised13; abort();14; }15 16target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"17target triple = "x86_64-unknown-linux-gnu"18 19define void @test_quiet_nan() {20 %1 = alloca double, align 821 store volatile double 0x7FF8000000000000, ptr %1, align 822 %2 = tail call i32 @feclearexcept(i32 noundef 61)23 %3 = load volatile double, ptr %1, align 824 %4 = call double @acos(double noundef %3)25; CHECK: [[COND1:%[0-9]+]] = fcmp ogt double [[VALUE:%.*]], 1.000000e+0026; CHECK: [[COND1:%[0-9]+]] = fcmp olt double [[VALUE]], -1.000000e+0027 %5 = call i32 @fetestexcept(i32 noundef 61)28 %6 = icmp ne i32 %5, 029 br i1 %6, label %abort, label %ret30 31abort:32 call void @abort()33 unreachable34 35ret:36 ret void37}38 39define void @test_quiet_nan_strictfp() strictfp {40 %1 = alloca double, align 841 store volatile double 0x7FF8000000000000, ptr %1, align 842 %2 = tail call i32 @feclearexcept(i32 noundef 61) strictfp43 %3 = load volatile double, ptr %1, align 844 %4 = call double @acos(double noundef %3) strictfp45; 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) strictfp50 %6 = icmp ne i32 %5, 051 br i1 %6, label %abort, label %ret52 53abort:54 call void @abort() strictfp55 unreachable56 57ret:58 ret void59}60 61declare i32 @feclearexcept(i32 noundef)62 63declare i32 @fetestexcept(i32 noundef)64 65declare double @acos(double noundef)66 67declare void @abort()68