Fix a fairly major performance problem. If a PHI node had a constant as

an incoming value from a block, the selector would evaluate the constant
at the TOP of the block instead of at the end of the block.  This made the
live range for the constant span the entire block, increasing register
pressure needlessly.

llvm-svn: 12542
This commit is contained in:
Chris Lattner 2004-03-30 19:10:12 +00:00
parent 1a0e9ac2f5
commit 0048e574fb
1 changed files with 18 additions and 11 deletions

View File

@ -597,6 +597,7 @@ void ISel::SelectPHINodes() {
// If this is a constant or GlobalValue, we may have to insert code
// into the basic block to compute it into a virtual register.
if (isa<Constant>(Val) || isa<GlobalValue>(Val)) {
if (isa<ConstantExpr>(Val)) {
// Because we don't want to clobber any values which might be in
// physical registers with the computation of this constant (which
// might be arbitrarily complex if it is a constant expression),
@ -608,6 +609,12 @@ void ISel::SelectPHINodes() {
++PI;
ValReg = getReg(Val, PredMBB, PI);
} else {
// Simple constants get emitted at the end of the basic block,
// before any terminator instructions. We "know" that the code to
// move a constant into a register will never clobber any flags.
ValReg = getReg(Val, PredMBB, PredMBB->getFirstTerminator());
}
} else {
ValReg = getReg(Val);
}