[llvm-commits] [llvm] r56315 - /llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
Devang Patel
dpatel at apple.com
Thu Sep 18 15:50:42 PDT 2008
Author: dpatel
Date: Thu Sep 18 17:50:42 2008
New Revision: 56315
URL: http://llvm.org/viewvc/llvm-project?rev=56315&view=rev
Log:
Try to place hoisted instructions befoe icmp instruction.
Modified:
llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=56315&r1=56314&r2=56315&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Thu Sep 18 17:50:42 2008
@@ -1046,8 +1046,29 @@
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.
More information about the llvm-commits
mailing list