forked from OSchip/llvm-project
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:
parent
1a0e9ac2f5
commit
0048e574fb
|
@ -597,6 +597,7 @@ void ISel::SelectPHINodes() {
|
||||||
// If this is a constant or GlobalValue, we may have to insert code
|
// If this is a constant or GlobalValue, we may have to insert code
|
||||||
// into the basic block to compute it into a virtual register.
|
// into the basic block to compute it into a virtual register.
|
||||||
if (isa<Constant>(Val) || isa<GlobalValue>(Val)) {
|
if (isa<Constant>(Val) || isa<GlobalValue>(Val)) {
|
||||||
|
if (isa<ConstantExpr>(Val)) {
|
||||||
// Because we don't want to clobber any values which might be in
|
// Because we don't want to clobber any values which might be in
|
||||||
// physical registers with the computation of this constant (which
|
// physical registers with the computation of this constant (which
|
||||||
// might be arbitrarily complex if it is a constant expression),
|
// might be arbitrarily complex if it is a constant expression),
|
||||||
|
@ -608,6 +609,12 @@ void ISel::SelectPHINodes() {
|
||||||
++PI;
|
++PI;
|
||||||
|
|
||||||
ValReg = getReg(Val, PredMBB, 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 {
|
} else {
|
||||||
ValReg = getReg(Val);
|
ValReg = getReg(Val);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue