summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/Float2Int/toolarge.ll
diff options
context:
space:
mode:
authorJames Molloy <james.molloy@arm.com>2015-03-24 11:15:23 +0000
committerJames Molloy <james.molloy@arm.com>2015-03-24 11:15:23 +0000
commit408df5160ca4e51d01d32c7c3e11b34c8150718a (patch)
tree2324021cf8679324be8590c763becf7d2d94ff31 /llvm/test/Transforms/Float2Int/toolarge.ll
parent7cb18bf537ed319eaa06f12ed39f85594bed641a (diff)
downloadbcm5719-llvm-408df5160ca4e51d01d32c7c3e11b34c8150718a.tar.gz
bcm5719-llvm-408df5160ca4e51d01d32c7c3e11b34c8150718a.zip
"float2int": Add a new pass to demote from float to int where possible.
It is possible to have code that converts from integer to float, performs operations then converts back, and the result is provably the same as if integers were used. This can come from different sources, but the most obvious is a helper function that uses floats but the arguments given at an inlined callsites are integers. This pass considers all integers requiring a bitwidth less than or equal to the bitwidth of the mantissa of a floating point type (23 for floats, 52 for doubles) as exactly representable in floating point. To reduce the risk of harming efficient code, the pass only attempts to perform complete removal of inttofp/fptoint operations, not just move them around. llvm-svn: 233062
Diffstat (limited to 'llvm/test/Transforms/Float2Int/toolarge.ll')
-rw-r--r--llvm/test/Transforms/Float2Int/toolarge.ll16
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/test/Transforms/Float2Int/toolarge.ll b/llvm/test/Transforms/Float2Int/toolarge.ll
new file mode 100644
index 00000000000..b5d77815768
--- /dev/null
+++ b/llvm/test/Transforms/Float2Int/toolarge.ll
@@ -0,0 +1,16 @@
+; RUN: opt < %s -float2int -float2int-max-integer-bw=256 -S | FileCheck %s
+
+; CHECK-LABEL: @neg_toolarge
+; CHECK: %1 = uitofp i80 %a to fp128
+; CHECK: %2 = fadd fp128 %1, %1
+; CHECK: %3 = fptoui fp128 %2 to i80
+; CHECK: ret i80 %3
+; fp128 has a 112-bit mantissa, which can hold an i80. But we only support
+; up to i64, so it should fail (even though the max integer bitwidth is 256).
+define i80 @neg_toolarge(i80 %a) {
+ %1 = uitofp i80 %a to fp128
+ %2 = fadd fp128 %1, %1
+ %3 = fptoui fp128 %2 to i80
+ ret i80 %3
+}
+
OpenPOWER on IntegriCloud