diff options
author | Eli Bendersky <eliben@chromium.org> | 2013-07-10 08:54:29 -0700 |
---|---|---|
committer | Eli Bendersky <eliben@chromium.org> | 2013-07-10 08:54:29 -0700 |
commit | f69ebb4201da8bb5045f9335150ed6ef6bcfc2cc (patch) | |
tree | 6d0ef75997255e633806335ddf7e8647dbcd5459 /test/CodeGen | |
parent | 3ae70608405cf8180c89f8d3393049b4acd58104 (diff) |
Cherry-picking the pow-for-le32 fix from upstream clang.
SVN log from upstream clang:
r185568 | eliben | 2013-07-03 12:19:12 -0700 (Wed, 03 Jul 2013)
Add target hook CodeGen queries when generating builtin pow*.
Without fmath-errno, Clang currently generates calls to @llvm.pow.* intrinsics
when it sees pow*(). This may not be suitable for all targets (for
example le32/PNaCl), so the attached patch adds a target hook that CodeGen
queries. The target can state its preference for having or not having the
intrinsic generated. Non-PNaCl behavior remains unchanged;
PNaCl-specific test added.
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3513
R=dschuff@chromium.org
Review URL: https://codereview.chromium.org/18953003
Diffstat (limited to 'test/CodeGen')
-rw-r--r-- | test/CodeGen/le32-libcall-pow.c | 21 | ||||
-rw-r--r-- | test/CodeGen/libcalls.c | 15 |
2 files changed, 28 insertions, 8 deletions
diff --git a/test/CodeGen/le32-libcall-pow.c b/test/CodeGen/le32-libcall-pow.c new file mode 100644 index 0000000000..c2f892c3ae --- /dev/null +++ b/test/CodeGen/le32-libcall-pow.c @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -fmath-errno -emit-llvm -o - %s -triple le32-unknown-nacl | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - %s -triple le32-unknown-nacl | FileCheck %s + +// le32 (PNaCl) never generates intrinsics for pow calls, with or without errno + +// CHECK: define void @test_pow +void test_pow(float a0, double a1, long double a2) { + // CHECK: call float @powf + float l0 = powf(a0, a0); + + // CHECK: call double @pow + double l1 = pow(a1, a1); + + // CHECK: call double @powl + long double l2 = powl(a2, a2); +} + +// CHECK: declare float @powf(float, float) +// CHECK: declare double @pow(double, double) +// CHECK: declare double @powl(double, double) + diff --git a/test/CodeGen/libcalls.c b/test/CodeGen/libcalls.c index 87e0592337..8f8e18226a 100644 --- a/test/CodeGen/libcalls.c +++ b/test/CodeGen/libcalls.c @@ -31,27 +31,25 @@ void test_sqrt(float a0, double a1, long double a2) { // CHECK-YES: define void @test_pow // CHECK-NO: define void @test_pow void test_pow(float a0, double a1, long double a2) { - // LOCALMOD: for PNaCl we generate lib calls and not intrinsics, even without - // errno. For more details see the LOCALMOD in lib/CodeGen/CGBuiltin.cpp // CHECK-YES: call float @powf - // CHECK-NO: call float @powf + // CHECK-NO: call float @llvm.pow.f32 float l0 = powf(a0, a0); // CHECK-YES: call double @pow - // CHECK-NO: call double @pow + // CHECK-NO: call double @llvm.pow.f64 double l1 = pow(a1, a1); // CHECK-YES: call x86_fp80 @powl - // CHECK-NO: call x86_fp80 @powl + // CHECK-NO: call x86_fp80 @llvm.pow.f80 long double l2 = powl(a2, a2); } // CHECK-YES: declare float @powf(float, float) // CHECK-YES: declare double @pow(double, double) // CHECK-YES: declare x86_fp80 @powl(x86_fp80, x86_fp80) -// CHECK-NO: declare float @powf(float, float) -// CHECK-NO: declare double @pow(double, double) -// CHECK-NO: declare x86_fp80 @powl(x86_fp80, x86_fp80) +// CHECK-NO: declare float @llvm.pow.f32(float, float) [[NUW_RO:#[0-9]+]] +// CHECK-NO: declare double @llvm.pow.f64(double, double) [[NUW_RO]] +// CHECK-NO: declare x86_fp80 @llvm.pow.f80(x86_fp80, x86_fp80) [[NUW_RO]] // CHECK-YES: define void @test_fma // CHECK-NO: define void @test_fma @@ -124,3 +122,4 @@ void test_builtins(double d, float f, long double ld) { // CHECK-YES: attributes [[NUW_RN]] = { nounwind readnone } // CHECK-NO: attributes [[NUW_RN]] = { nounwind readnone{{.*}} } +// CHECK-NO: attributes [[NUW_RO]] = { nounwind readonly } |