aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMichael Kuperstein <michael.m.kuperstein@intel.com>2013-08-19 06:55:47 +0000
committerMichael Kuperstein <michael.m.kuperstein@intel.com>2013-08-19 06:55:47 +0000
commit2063637fa7c9ebc880cf858674eb45727d4ea295 (patch)
treecd592484d3021840d068faf0e36e852ef0bf7c53 /test
parenta0e735ee16f439675c1842e47ba3149aa226bdc0 (diff)
downloadexternal_llvm-2063637fa7c9ebc880cf858674eb45727d4ea295.zip
external_llvm-2063637fa7c9ebc880cf858674eb45727d4ea295.tar.gz
external_llvm-2063637fa7c9ebc880cf858674eb45727d4ea295.tar.bz2
Adds missing TLI check for library simplification of
* pow(x, 0.5) -> fabs(sqrt(x)) * pow(2.0, x) -> exp2(x) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188656 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/Transforms/InstCombine/pow-1.ll13
-rw-r--r--test/Transforms/InstCombine/pow-3.ll12
2 files changed, 25 insertions, 0 deletions
diff --git a/test/Transforms/InstCombine/pow-1.ll b/test/Transforms/InstCombine/pow-1.ll
index 0fdafeb..9f1d073 100644
--- a/test/Transforms/InstCombine/pow-1.ll
+++ b/test/Transforms/InstCombine/pow-1.ll
@@ -151,4 +151,17 @@ define double @test_simplify16(double %x) {
; CHECK-NEXT: ret double [[RECIPROCAL]]
}
+declare double @llvm.pow.f64(double %Val, double %Power)
+define double @test_simplify17(double %x) {
+; CHECK-LABEL: @test_simplify17(
+ %retval = call double @llvm.pow.f64(double %x, double 0.5)
+; CHECK-NEXT: [[SQRT:%[a-z0-9]+]] = call double @sqrt(double %x) [[NUW_RO]]
+; CHECK-NEXT: [[FABS:%[a-z0-9]+]] = call double @fabs(double [[SQRT]]) [[NUW_RO]]
+; CHECK-NEXT: [[FCMP:%[a-z0-9]+]] = fcmp oeq double %x, 0xFFF0000000000000
+; CHECK-NEXT: [[SELECT:%[a-z0-9]+]] = select i1 [[FCMP]], double 0x7FF0000000000000, double [[FABS]]
+ ret double %retval
+; CHECK-NEXT: ret double [[SELECT]]
+}
+
; CHECK: attributes [[NUW_RO]] = { nounwind readonly }
+
diff --git a/test/Transforms/InstCombine/pow-3.ll b/test/Transforms/InstCombine/pow-3.ll
new file mode 100644
index 0000000..1c5cf91
--- /dev/null
+++ b/test/Transforms/InstCombine/pow-3.ll
@@ -0,0 +1,12 @@
+; Test that the pow won't get simplified to sqrt(fabs) when they are not available.
+;
+; RUN: opt < %s -disable-simplify-libcalls -instcombine -S | FileCheck %s
+
+declare double @llvm.pow.f64(double %Val, double %Power)
+
+define double @test_simplify_unavailable(double %x) {
+; CHECK-LABEL: @test_simplify_unavailable(
+ %retval = call double @llvm.pow.f64(double %x, double 0.5)
+; CHECK-NEXT: call double @llvm.pow.f64(double %x, double 5.000000e-01)
+ ret double %retval
+}