aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-09-16 02:01:52 +0000
committerDan Gohman <gohman@apple.com>2009-09-16 02:01:52 +0000
commitb6c3385a2dd3aea255f70d62e8ab31a562449f4f (patch)
tree6fcc5ac06624dfa8adadc1280c9c2e39a8f0d75b /lib/Transforms
parent60b995418fef7c0a3acaa7e56b94bf0353b1974b (diff)
downloadexternal_llvm-b6c3385a2dd3aea255f70d62e8ab31a562449f4f.zip
external_llvm-b6c3385a2dd3aea255f70d62e8ab31a562449f4f.tar.gz
external_llvm-b6c3385a2dd3aea255f70d62e8ab31a562449f4f.tar.bz2
Don't sink gep operators through phi nodes if the result would require
more than one phi, since that leads to higher register pressure on entry to the phi. This is especially problematic when the phi is in a loop header, as it increases register pressure throughout the loop. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81993 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 47a02bd..006d67b 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -326,7 +326,7 @@ namespace {
// instruction. Instead, visit methods should return the value returned by
// this function.
Instruction *EraseInstFromFunction(Instruction &I) {
- DEBUG(errs() << "IC: erase " << I);
+ DEBUG(errs() << "IC: erase " << I << '\n');
assert(I.use_empty() && "Cannot erase instruction that is used!");
// Make sure that we reprocess all operands now that we reduced their
@@ -10401,6 +10401,10 @@ Instruction *InstCombiner::FoldPHIArgGEPIntoPHI(PHINode &PN) {
// This is true if all GEP bases are allocas and if all indices into them are
// constants.
bool AllBasePointersAreAllocas = true;
+
+ // We don't want to replace this phi if the replacement would require
+ // more than one phi.
+ bool NeededPhi = false;
// Scan to see if all operands are the same opcode, all have one use, and all
// kill their operands (i.e. the operands have one use).
@@ -10432,7 +10436,16 @@ Instruction *InstCombiner::FoldPHIArgGEPIntoPHI(PHINode &PN) {
if (FirstInst->getOperand(op)->getType() !=GEP->getOperand(op)->getType())
return 0;
+
+ // If we already needed a PHI for an earlier operand, and another operand
+ // also requires a PHI, we'd be introducing more PHIs than we're
+ // eliminating, which increases register pressure on entry to the PHI's
+ // block.
+ if (NeededPhi)
+ return 0;
+
FixedOperands[op] = 0; // Needs a PHI.
+ NeededPhi = true;
}
}