| John McCall | 8586bfd | 2010-04-07 08:20:20 +0000 | [diff] [blame] | 1 | // 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 Dunbar | 8eb018a | 2009-02-16 22:43:43 +0000 | [diff] [blame] | 3 |  | 
| John McCall | 8586bfd | 2010-04-07 08:20:20 +0000 | [diff] [blame] | 4 | // CHECK-YES: define void @test_sqrt | 
|  | 5 | // CHECK-NO: define void @test_sqrt | 
| Daniel Dunbar | 8eb018a | 2009-02-16 22:43:43 +0000 | [diff] [blame] | 6 | void test_sqrt(float a0, double a1, long double a2) { | 
| John McCall | 8586bfd | 2010-04-07 08:20:20 +0000 | [diff] [blame] | 7 | // 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 Dunbar | 8eb018a | 2009-02-16 22:43:43 +0000 | [diff] [blame] | 13 | float l0 = sqrtf(a0); | 
| John McCall | 8586bfd | 2010-04-07 08:20:20 +0000 | [diff] [blame] | 14 |  | 
|  | 15 | // CHECK-YES: call double @sqrt | 
|  | 16 | // CHECK-NO: call double @sqrt | 
| Daniel Dunbar | 8eb018a | 2009-02-16 22:43:43 +0000 | [diff] [blame] | 17 | double l1 = sqrt(a1); | 
| John McCall | 8586bfd | 2010-04-07 08:20:20 +0000 | [diff] [blame] | 18 |  | 
|  | 19 | // CHECK-YES: call x86_fp80 @sqrtl | 
|  | 20 | // CHECK-NO: call x86_fp80 @sqrtl | 
| Daniel Dunbar | 8eb018a | 2009-02-16 22:43:43 +0000 | [diff] [blame] | 21 | long double l2 = sqrtl(a2); | 
|  | 22 | } | 
|  | 23 |  | 
| John McCall | 8586bfd | 2010-04-07 08:20:20 +0000 | [diff] [blame] | 24 | // 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 Dunbar | 8eb018a | 2009-02-16 22:43:43 +0000 | [diff] [blame] | 33 | void test_pow(float a0, double a1, long double a2) { | 
| John McCall | 8586bfd | 2010-04-07 08:20:20 +0000 | [diff] [blame] | 34 | // CHECK-YES: call float @powf | 
|  | 35 | // CHECK-NO: call float @llvm.pow.f32 | 
| Daniel Dunbar | 8eb018a | 2009-02-16 22:43:43 +0000 | [diff] [blame] | 36 | float l0 = powf(a0, a0); | 
| John McCall | 8586bfd | 2010-04-07 08:20:20 +0000 | [diff] [blame] | 37 |  | 
|  | 38 | // CHECK-YES: call double @pow | 
|  | 39 | // CHECK-NO: call double @llvm.pow.f64 | 
| Daniel Dunbar | 8eb018a | 2009-02-16 22:43:43 +0000 | [diff] [blame] | 40 | double l1 = pow(a1, a1); | 
| John McCall | 8586bfd | 2010-04-07 08:20:20 +0000 | [diff] [blame] | 41 |  | 
|  | 42 | // CHECK-YES: call x86_fp80 @powl | 
|  | 43 | // CHECK-NO: call x86_fp80 @llvm.pow.f80 | 
| Daniel Dunbar | 8eb018a | 2009-02-16 22:43:43 +0000 | [diff] [blame] | 44 | long double l2 = powl(a2, a2); | 
|  | 45 | } | 
| John McCall | 8586bfd | 2010-04-07 08:20:20 +0000 | [diff] [blame] | 46 |  | 
|  | 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 |