summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2015-02-25 18:00:15 +0000
committerSanjay Patel <spatel@rotateright.com>2015-02-25 18:00:15 +0000
commit40eaa8df99982568bc71017e8a2e79242dbe0c5a (patch)
treec068b26a5d7adafc7c11551ba2e2070b886a4f6c /llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll
parentd9b8bd6b86add43cd9dde62674e8465adc8e911a (diff)
downloadbcm5719-llvm-40eaa8df99982568bc71017e8a2e79242dbe0c5a.tar.gz
bcm5719-llvm-40eaa8df99982568bc71017e8a2e79242dbe0c5a.zip
Fix really obscure bug in CannotBeNegativeZero() (PR22688)
With a diabolically crafted test case, we could recurse through this code and return true instead of false. The larger engineering crime is the use of magic numbers. Added FIXME comments for those. llvm-svn: 230515
Diffstat (limited to 'llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll')
-rw-r--r--llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll26
1 files changed, 26 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll b/llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll
index 8177440472c..b0957a81773 100644
--- a/llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll
+++ b/llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll
@@ -33,3 +33,29 @@ define double @fmul_X_1(double %a) {
; CHECK: ret double %a
ret double %b
}
+
+; We can't optimize away the fadd in this test because the input
+; value to the function and subsequently to the fadd may be -0.0.
+; In that one special case, the result of the fadd should be +0.0
+; rather than the first parameter of the fadd.
+
+; Fragile test warning: We need 6 sqrt calls to trigger the bug
+; because the internal logic has a magic recursion limit of 6.
+; This is presented without any explanation or ability to customize.
+
+declare float @sqrtf(float)
+
+define float @PR22688(float %x) {
+ %1 = call float @sqrtf(float %x)
+ %2 = call float @sqrtf(float %1)
+ %3 = call float @sqrtf(float %2)
+ %4 = call float @sqrtf(float %3)
+ %5 = call float @sqrtf(float %4)
+ %6 = call float @sqrtf(float %5)
+ %7 = fadd float %6, 0.0
+ ret float %7
+
+; CHECK-LABEL: @PR22688(
+; CHECK: fadd float %6, 0.0
+}
+
OpenPOWER on IntegriCloud