blob: 828d7de6cb086342b9ecd2a4b377d49fae589ee2 [file] [log] [blame]
John McCallbeb41282010-04-07 08:20:20 +00001// RUN: %clang_cc1 -fmath-errno -emit-llvm -o - %s -triple i386-unknown-unknown | FileCheck -check-prefix YES %s
2// RUN: %clang_cc1 -emit-llvm -o - %s -triple i386-unknown-unknown | FileCheck -check-prefix NO %s
Daniel Dunbaref2abfe2009-02-16 22:43:43 +00003
John McCallbeb41282010-04-07 08:20:20 +00004// CHECK-YES: define void @test_sqrt
5// CHECK-NO: define void @test_sqrt
Daniel Dunbaref2abfe2009-02-16 22:43:43 +00006void test_sqrt(float a0, double a1, long double a2) {
John McCallbeb41282010-04-07 08:20:20 +00007 // Following llvm-gcc's lead, we never emit these as intrinsics;
8 // no-math-errno isn't good enough. We could probably use intrinsics
9 // with appropriate guards if it proves worthwhile.
10
11 // CHECK-YES: call float @sqrtf
12 // CHECK-NO: call float @sqrtf
Daniel Dunbaref2abfe2009-02-16 22:43:43 +000013 float l0 = sqrtf(a0);
John McCallbeb41282010-04-07 08:20:20 +000014
15 // CHECK-YES: call double @sqrt
16 // CHECK-NO: call double @sqrt
Daniel Dunbaref2abfe2009-02-16 22:43:43 +000017 double l1 = sqrt(a1);
John McCallbeb41282010-04-07 08:20:20 +000018
19 // CHECK-YES: call x86_fp80 @sqrtl
20 // CHECK-NO: call x86_fp80 @sqrtl
Daniel Dunbaref2abfe2009-02-16 22:43:43 +000021 long double l2 = sqrtl(a2);
22}
23
John McCallbeb41282010-04-07 08:20:20 +000024// CHECK-YES: declare float @sqrtf(float)
25// CHECK-YES: declare double @sqrt(double)
26// CHECK-YES: declare x86_fp80 @sqrtl(x86_fp80)
27// CHECK-NO: declare float @sqrtf(float) readnone
28// CHECK-NO: declare double @sqrt(double) readnone
29// CHECK-NO: declare x86_fp80 @sqrtl(x86_fp80) readnone
30
31// CHECK-YES: define void @test_pow
32// CHECK-NO: define void @test_pow
Daniel Dunbaref2abfe2009-02-16 22:43:43 +000033void test_pow(float a0, double a1, long double a2) {
John McCallbeb41282010-04-07 08:20:20 +000034 // CHECK-YES: call float @powf
35 // CHECK-NO: call float @llvm.pow.f32
Daniel Dunbaref2abfe2009-02-16 22:43:43 +000036 float l0 = powf(a0, a0);
John McCallbeb41282010-04-07 08:20:20 +000037
38 // CHECK-YES: call double @pow
39 // CHECK-NO: call double @llvm.pow.f64
Daniel Dunbaref2abfe2009-02-16 22:43:43 +000040 double l1 = pow(a1, a1);
John McCallbeb41282010-04-07 08:20:20 +000041
42 // CHECK-YES: call x86_fp80 @powl
43 // CHECK-NO: call x86_fp80 @llvm.pow.f80
Daniel Dunbaref2abfe2009-02-16 22:43:43 +000044 long double l2 = powl(a2, a2);
45}
John McCallbeb41282010-04-07 08:20:20 +000046
47// CHECK-YES: declare float @powf(float, float)
48// CHECK-YES: declare double @pow(double, double)
49// CHECK-YES: declare x86_fp80 @powl(x86_fp80, x86_fp80)
50// CHECK-NO: declare float @llvm.pow.f32(float, float) nounwind readonly
51// CHECK-NO: declare double @llvm.pow.f64(double, double) nounwind readonly
52// CHECK-NO: declare x86_fp80 @llvm.pow.f80(x86_fp80, x86_fp80) nounwind readonly