llvm-6502/lib
Juergen Ributzka fb282c68b7 Add Constant Hoisting Pass
This pass identifies expensive constants to hoist and coalesces them to
better prepare it for SelectionDAG-based code generation. This works around the
limitations of the basic-block-at-a-time approach.

First it scans all instructions for integer constants and calculates its
cost. If the constant can be folded into the instruction (the cost is
TCC_Free) or the cost is just a simple operation (TCC_BASIC), then we don't
consider it expensive and leave it alone. This is the default behavior and
the default implementation of getIntImmCost will always return TCC_Free.

If the cost is more than TCC_BASIC, then the integer constant can't be folded
into the instruction and it might be beneficial to hoist the constant.
Similar constants are coalesced to reduce register pressure and
materialization code.

When a constant is hoisted, it is also hidden behind a bitcast to force it to
be live-out of the basic block. Otherwise the constant would be just
duplicated and each basic block would have its own copy in the SelectionDAG.
The SelectionDAG recognizes such constants as opaque and doesn't perform
certain transformations on them, which would create a new expensive constant.

This optimization is only applied to integer constants in instructions and
simple (this means not nested) constant cast experessions. For example:
%0 = load i64* inttoptr (i64 big_constant to i64*)

Reviewed by Eric

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200022 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-24 18:23:08 +00:00
..
Analysis Add Constant Hoisting Pass 2014-01-24 18:23:08 +00:00
AsmParser
Bitcode
CodeGen Add Constant Hoisting Pass 2014-01-24 18:23:08 +00:00
DebugInfo DWARFContext: Fix possible memory leak since r198908. 2014-01-24 13:40:43 +00:00
ExecutionEngine Fix known typos 2014-01-24 17:20:08 +00:00
IR
IRReader
Linker
LTO Most streamers' InitSections just create a text section. Make that the default 2014-01-24 02:42:26 +00:00
MC Fix known typos 2014-01-24 17:20:08 +00:00
Object
Option
Support Fix known typos 2014-01-24 17:20:08 +00:00
TableGen
Target Add Constant Hoisting Pass 2014-01-24 18:23:08 +00:00
Transforms Add Constant Hoisting Pass 2014-01-24 18:23:08 +00:00
CMakeLists.txt
LLVMBuild.txt
Makefile