summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/InstCombine/double-float-shrink-1.ll
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2014-10-23 21:52:45 +0000
committerSanjay Patel <spatel@rotateright.com>2014-10-23 21:52:45 +0000
commit848309da7c1861b328d775b28b03d8f687ebeb5c (patch)
tree8706329fab0f2e6c19524bb82d49a520ac635af6 /llvm/test/Transforms/InstCombine/double-float-shrink-1.ll
parentecbe7c03a03bcb04b0a2fb185d331b6b6f404322 (diff)
downloadbcm5719-llvm-848309da7c1861b328d775b28b03d8f687ebeb5c.tar.gz
bcm5719-llvm-848309da7c1861b328d775b28b03d8f687ebeb5c.zip
Handle sqrt() shrinking in SimplifyLibCalls like any other call
This patch removes a chunk of special case logic for folding (float)sqrt((double)x) -> sqrtf(x) in InstCombineCasts and handles it in the mainstream path of SimplifyLibCalls. No functional change intended, but I loosened the restriction on the existing sqrt testcases to allow for this optimization even without unsafe-fp-math because that's the existing behavior. I also added a missing test case for not shrinking the llvm.sqrt.f64 intrinsic in case the result is used as a double. Differential Revision: http://reviews.llvm.org/D5919 llvm-svn: 220514
Diffstat (limited to 'llvm/test/Transforms/InstCombine/double-float-shrink-1.ll')
-rw-r--r--llvm/test/Transforms/InstCombine/double-float-shrink-1.ll25
1 files changed, 19 insertions, 6 deletions
diff --git a/llvm/test/Transforms/InstCombine/double-float-shrink-1.ll b/llvm/test/Transforms/InstCombine/double-float-shrink-1.ll
index 9b422b77296..63a02bbd857 100644
--- a/llvm/test/Transforms/InstCombine/double-float-shrink-1.ll
+++ b/llvm/test/Transforms/InstCombine/double-float-shrink-1.ll
@@ -279,6 +279,14 @@ define float @sqrt_test(float %f) {
; CHECK: call float @sqrtf(float %f)
}
+define double @sqrt_test2(float %f) {
+ %conv = fpext float %f to double
+ %call = call double @sqrt(double %conv)
+ ret double %call
+; CHECK-LABEL: sqrt_test2
+; CHECK: call double @sqrt(double %conv)
+}
+
define float @sqrt_int_test(float %f) {
%conv = fpext float %f to double
%call = call double @llvm.sqrt.f64(double %conv)
@@ -288,13 +296,14 @@ define float @sqrt_int_test(float %f) {
; CHECK: call float @llvm.sqrt.f32(float %f)
}
-define double @sqrt_test2(float %f) {
+define double @sqrt_int_test2(float %f) {
%conv = fpext float %f to double
- %call = call double @sqrt(double %conv)
+ %call = call double @llvm.sqrt.f64(double %conv)
ret double %call
-; CHECK-LABEL: sqrt_test2
-; CHECK: call double @sqrt(double %conv)
+; CHECK-LABEL: sqrt_int_test2
+; CHECK: call double @llvm.sqrt.f64(double %conv)
}
+
define float @tan_test(float %f) {
%conv = fpext float %f to double
%call = call double @tan(double %conv)
@@ -330,7 +339,12 @@ define double @tanh_test2(float %f) {
declare double @tanh(double) #1
declare double @tan(double) #1
-declare double @sqrt(double) #1
+
+; sqrt is a special case: the shrinking optimization
+; is valid even without unsafe-fp-math.
+declare double @sqrt(double)
+declare double @llvm.sqrt.f64(double)
+
declare double @sin(double) #1
declare double @log2(double) #1
declare double @log1p(double) #1
@@ -348,6 +362,5 @@ declare double @acosh(double) #1
declare double @asin(double) #1
declare double @asinh(double) #1
-declare double @llvm.sqrt.f64(double) #1
attributes #1 = { "unsafe-fp-math"="true" }
OpenPOWER on IntegriCloud