summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2008-09-18 22:50:42 +0000
committerDevang Patel <dpatel@apple.com>2008-09-18 22:50:42 +0000
commit76b22c142016775030f55958890048ff0e06d557 (patch)
tree8faf9a1f0d72e9a0cd7320b7d4f0f9a54e55fa70 /llvm/lib/Transforms
parent3d9416cf240a3298946b9507a183f594a98f9b43 (diff)
downloadbcm5719-llvm-76b22c142016775030f55958890048ff0e06d557.tar.gz
bcm5719-llvm-76b22c142016775030f55958890048ff0e06d557.zip
Try to place hoisted instructions befoe icmp instruction.
llvm-svn: 56315
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyCFG.cpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 39163e40504..587dac67673 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1046,8 +1046,29 @@ static bool SpeculativelyExecuteBB(BranchInst *BI, BasicBlock *BB1) {
return false;
}
- // If we get here, we can hoist the instruction.
- BIParent->getInstList().splice(BI, BB1->getInstList(), I);
+ // If we get here, we can hoist the instruction. Try to place it
+ // before the icmp instruction preceeding the conditional branch.
+ BasicBlock::iterator InsertPos = BI;
+ if (InsertPos != BIParent->begin())
+ --InsertPos;
+ if (InsertPos == BrCond) {
+ SmallPtrSet<Instruction *, 4> BB1Insns;
+ for(BasicBlock::iterator BB1I = BB1->begin(), BB1E = BB1->end();
+ BB1I != BB1E; ++BB1I)
+ BB1Insns.insert(BB1I);
+ for(Value::use_iterator UI = BrCond->use_begin(), UE = BrCond->use_end();
+ UI != UE; ++UI) {
+ Instruction *Use = cast<Instruction>(*UI);
+ if (BB1Insns.count(Use)) {
+ // If BrCond uses the instruction that place it just before
+ // branch instruction.
+ InsertPos = BI;
+ break;
+ }
+ }
+ } else
+ InsertPos = BI;
+ BIParent->getInstList().splice(InsertPos, BB1->getInstList(), I);
// Create a select whose true value is the speculatively executed value and
// false value is the previously determined FalseV.
OpenPOWER on IntegriCloud