"float2int": Add a new pass to demote from float to int where possible.
authorJames Molloy <james.molloy@arm.com>
Tue, 24 Mar 2015 11:15:23 +0000 (11:15 +0000)
committerJames Molloy <james.molloy@arm.com>
Tue, 24 Mar 2015 11:15:23 +0000 (11:15 +0000)
commita54c5b44893b4bf0ae5ebb8df494b96adeb71687
tree187dee815276a702cc3a4c6d9fc5dd8f704ef92e
parentd3ab717935803275fc7af3915be0c1678feec001
"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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233062 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/InitializePasses.h
include/llvm/LinkAllPasses.h
include/llvm/Transforms/Scalar.h
lib/Transforms/IPO/PassManagerBuilder.cpp
lib/Transforms/Scalar/CMakeLists.txt
lib/Transforms/Scalar/Float2Int.cpp [new file with mode: 0644]
lib/Transforms/Scalar/Scalar.cpp
test/Transforms/Float2Int/basic.ll [new file with mode: 0644]
test/Transforms/Float2Int/toolarge.ll [new file with mode: 0644]