summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/ConstProp
diff options
context:
space:
mode:
authorBixia Zheng <bixia@google.com>2019-03-22 16:37:37 +0000
committerBixia Zheng <bixia@google.com>2019-03-22 16:37:37 +0000
commitbdf0230cffd13425a7f3492cc7c514fc60173537 (patch)
treed60d76459b69a4fbbe55c75fc0cf2a38d2fb6f11 /llvm/test/Transforms/ConstProp
parent71ebc9eb0b0586c7d995f42e14c1e0180cc299b9 (diff)
downloadbcm5719-llvm-bdf0230cffd13425a7f3492cc7c514fc60173537.tar.gz
bcm5719-llvm-bdf0230cffd13425a7f3492cc7c514fc60173537.zip
[ConstantFolding] Fix GetConstantFoldFPValue to avoid cast overflow.
Summary: In C++, the behavior of casting a double value that is beyond the range of a single precision floating-point to a float value is undefined. This change replaces such a cast with APFloat::convert to convert the value, which is consistent with how we convert a double value to a half value. Reviewers: sanjoy Subscribers: lebedev.ri, sanjoy, jlebar, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D59500 llvm-svn: 356781
Diffstat (limited to 'llvm/test/Transforms/ConstProp')
-rw-r--r--llvm/test/Transforms/ConstProp/calls.ll10
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/test/Transforms/ConstProp/calls.ll b/llvm/test/Transforms/ConstProp/calls.ll
index 161637cc92b..12ee1cb1139 100644
--- a/llvm/test/Transforms/ConstProp/calls.ll
+++ b/llvm/test/Transforms/ConstProp/calls.ll
@@ -193,4 +193,14 @@ entry:
ret double %0
}
+define float @test_intrinsic_pow_f32_overflow() nounwind uwtable ssp {
+entry:
+; CHECK-LABEL: @test_intrinsic_pow_f32_overflow(
+; CHECK-NOT: call
+; CHECK: ret float 0x7FF0000000000000
+ %0 = call float @llvm.pow.f32(float 40.0, float 50.0)
+ ret float %0
+}
+
declare double @llvm.pow.f64(double, double) nounwind readonly
+declare float @llvm.pow.f32(float, float) nounwind readonly
OpenPOWER on IntegriCloud