[Constant Hoisting] Change the algorithm to only track constants for instructions.
authorJuergen Ributzka <juergen@apple.com>
Fri, 21 Mar 2014 06:04:36 +0000 (06:04 +0000)
committerJuergen Ributzka <juergen@apple.com>
Fri, 21 Mar 2014 06:04:36 +0000 (06:04 +0000)
commit8ebaf637500a6bac4bf734b1c7e8600ac9add6f7
tree23c010a70f92196976e06828850bb2016b06710a
parent032dafd64ae1a9da38db41dde32de8066e8d518f
[Constant Hoisting] Change the algorithm to only track constants for instructions.

Originally the algorithm would search for expensive constants and track their
users, which could be instructions and constant expressions. This change only
tracks the constants for instructions, but constant expressions are indirectly
covered too. If an operand is an constant expression, then we look through the
expression to find anny expensive constants.

The algorithm keep now track of the instruction and the operand index where the
constant is used. This allows more precise hoisting of constant materialization
code for PHI instructions, because we only hoist to the basic block of the
incoming operand. Before we had to find the idom of all PHI operands and hoist
the materialization code there.

This also makes updating of instructions easier. Before we had to keep track of
the original constant, find it in the instructions, and then replace it. Now we
can just simply update the operand.

Related to <rdar://problem/16381500>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204433 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/ConstantHoisting.cpp
test/Transforms/ConstantHoisting/X86/phi.ll