John McCall | beb4128 | 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 | ef2abfe | 2009-02-16 22:43:43 +0000 | [diff] [blame] | 3 | |
John McCall | beb4128 | 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 | ef2abfe | 2009-02-16 22:43:43 +0000 | [diff] [blame] | 6 | void test_sqrt(float a0, double a1, long double a2) { |
John McCall | beb4128 | 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 | ef2abfe | 2009-02-16 22:43:43 +0000 | [diff] [blame] | 13 | float l0 = sqrtf(a0); |
John McCall | beb4128 | 2010-04-07 08:20:20 +0000 | [diff] [blame] | 14 | |
| 15 | // CHECK-YES: call double @sqrt |
| 16 | // CHECK-NO: call double @sqrt |
Daniel Dunbar | ef2abfe | 2009-02-16 22:43:43 +0000 | [diff] [blame] | 17 | double l1 = sqrt(a1); |
John McCall | beb4128 | 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 | ef2abfe | 2009-02-16 22:43:43 +0000 | [diff] [blame] | 21 | long double l2 = sqrtl(a2); |
| 22 | } |
| 23 | |
John McCall | beb4128 | 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) |
Eric Christopher | 041087c | 2011-08-15 22:38:22 +0000 | [diff] [blame] | 27 | // CHECK-NO: declare float @sqrtf(float) nounwind readnone |
| 28 | // CHECK-NO: declare double @sqrt(double) nounwind readnone |
| 29 | // CHECK-NO: declare x86_fp80 @sqrtl(x86_fp80) nounwind readnone |
John McCall | beb4128 | 2010-04-07 08:20:20 +0000 | [diff] [blame] | 30 | |
| 31 | // CHECK-YES: define void @test_pow |
| 32 | // CHECK-NO: define void @test_pow |
Daniel Dunbar | ef2abfe | 2009-02-16 22:43:43 +0000 | [diff] [blame] | 33 | void test_pow(float a0, double a1, long double a2) { |
John McCall | beb4128 | 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 | ef2abfe | 2009-02-16 22:43:43 +0000 | [diff] [blame] | 36 | float l0 = powf(a0, a0); |
John McCall | beb4128 | 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 | ef2abfe | 2009-02-16 22:43:43 +0000 | [diff] [blame] | 40 | double l1 = pow(a1, a1); |
John McCall | beb4128 | 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 | ef2abfe | 2009-02-16 22:43:43 +0000 | [diff] [blame] | 44 | long double l2 = powl(a2, a2); |
| 45 | } |
John McCall | beb4128 | 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 |
Cameron Zwarich | 094240a | 2011-07-08 21:39:34 +0000 | [diff] [blame] | 53 | |
| 54 | // CHECK-YES: define void @test_fma |
| 55 | // CHECK-NO: define void @test_fma |
| 56 | void test_fma(float a0, double a1, long double a2) { |
| 57 | // CHECK-YES: call float @llvm.fma.f32 |
| 58 | // CHECK-NO: call float @llvm.fma.f32 |
| 59 | float l0 = fmaf(a0, a0, a0); |
| 60 | |
| 61 | // CHECK-YES: call double @llvm.fma.f64 |
| 62 | // CHECK-NO: call double @llvm.fma.f64 |
| 63 | double l1 = fma(a1, a1, a1); |
| 64 | |
| 65 | // CHECK-YES: call x86_fp80 @llvm.fma.f80 |
| 66 | // CHECK-NO: call x86_fp80 @llvm.fma.f80 |
| 67 | long double l2 = fmal(a2, a2, a2); |
| 68 | } |
| 69 | |
| 70 | // CHECK-YES: declare float @llvm.fma.f32(float, float, float) nounwind readnone |
| 71 | // CHECK-YES: declare double @llvm.fma.f64(double, double, double) nounwind readnone |
| 72 | // CHECK-YES: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) nounwind readnone |
| 73 | // CHECK-NO: declare float @llvm.fma.f32(float, float, float) nounwind readnone |
| 74 | // CHECK-NO: declare double @llvm.fma.f64(double, double, double) nounwind readnone |
| 75 | // CHECK-NO: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) nounwind readnone |
Chad Rosier | 454393e | 2012-04-24 22:40:01 +0000 | [diff] [blame] | 76 | |
| 77 | // Just checking to make sure these library functions are marked readnone |
| 78 | void test_builtins(double d, float f, long double ld) { |
| 79 | // CHEC-NO: @test_builtins |
| 80 | // CHEC-YES: @test_builtins |
| 81 | double atan_ = atan(d); |
| 82 | long double atanl_ = atanl(ld); |
| 83 | float atanf_ = atanf(f); |
| 84 | // CHECK-NO: declare double @atan(double) nounwind readnone |
| 85 | // CHECK-NO: declare x86_fp80 @atanl(x86_fp80) nounwind readnone |
| 86 | // CHECK-NO: declare float @atanf(float) nounwind readnone |
| 87 | // CHECK-YES-NOT: declare double @atan(double) nounwind readnone |
| 88 | // CHECK-YES-NOT: declare x86_fp80 @atanl(x86_fp80) nounwind readnone |
| 89 | // CHECK-YES-NOT: declare float @atanf(float) nounwind readnone |
| 90 | |
| 91 | double atan2_ = atan2(d, 2); |
| 92 | long double atan2l_ = atan2l(ld, ld); |
| 93 | float atan2f_ = atan2f(f, f); |
| 94 | // CHECK-NO: declare double @atan2(double, double) nounwind readnone |
| 95 | // CHECK-NO: declare x86_fp80 @atan2l(x86_fp80, x86_fp80) nounwind readnone |
| 96 | // CHECK-NO: declare float @atan2f(float, float) nounwind readnone |
| 97 | // CHECK-YES-NOT: declare double @atan2(double, double) nounwind readnone |
| 98 | // CHECK-YES-NOT: declare x86_fp80 @atan2l(x86_fp80, x86_fp80) nounwind readnone |
| 99 | // CHECK-YES-NOT: declare float @atan2f(float, float) nounwind readnone |
| 100 | |
| 101 | double exp_ = exp(d); |
| 102 | long double expl_ = expl(ld); |
| 103 | float expf_ = expf(f); |
| 104 | // CHECK-NO: declare double @exp(double) nounwind readnone |
| 105 | // CHECK-NO: declare x86_fp80 @expl(x86_fp80) nounwind readnone |
| 106 | // CHECK-NO: declare float @expf(float) nounwind readnone |
| 107 | // CHECK-YES-NOT: declare double @exp(double) nounwind readnone |
| 108 | // CHECK-YES-NOT: declare x86_fp80 @expl(x86_fp80) nounwind readnone |
| 109 | // CHECK-YES-NOT: declare float @expf(float) nounwind readnone |
| 110 | |
| 111 | double log_ = log(d); |
| 112 | long double logl_ = logl(ld); |
| 113 | float logf_ = logf(f); |
| 114 | // CHECK-NO: declare double @log(double) nounwind readnone |
| 115 | // CHECK-NO: declare x86_fp80 @logl(x86_fp80) nounwind readnone |
| 116 | // CHECK-NO: declare float @logf(float) nounwind readnone |
| 117 | // CHECK-YES-NOT: declare double @log(double) nounwind readnone |
| 118 | // CHECK-YES-NOT: declare x86_fp80 @logl(x86_fp80) nounwind readnone |
| 119 | // CHECK-YES-NOT: declare float @logf(float) nounwind readnone |
| 120 | } |