diff options
author | Evan Cheng <evan.cheng@apple.com> | 2008-06-11 19:18:20 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2008-06-11 19:18:20 +0000 |
commit | 797d95188d00963a835db9ad66dd3c4a54aa2faf (patch) | |
tree | 40f31e802a80ffd3025fafd1f152f156ae0390d7 /lib/Transforms/Utils/SimplifyCFG.cpp | |
parent | bb318c073e0442ad86aa499ed329058ebce9b4c7 (diff) |
For now, avoid generating FP select instructions in order to speculatively execute integer arithmetic instructions. FP selects are more likely to be expensive (even compared to branch on fcmp). This is not a wonderful solution but I rather err on the side of conservative.
This fixes the heapsort performance regressions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52224 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r-- | lib/Transforms/Utils/SimplifyCFG.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp index c72806b9e2..605855d176 100644 --- a/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/lib/Transforms/Utils/SimplifyCFG.cpp @@ -965,6 +965,12 @@ static bool SpeculativelyExecuteBB(BranchInst *BI, BasicBlock *BB1) { if (BB1->size() != 2) return false; + // Be conservative for now. FP select instruction can often be expensive. + Value *BrCond = BI->getCondition(); + if (isa<Instruction>(BrCond) && + cast<Instruction>(BrCond)->getOpcode() == Instruction::FCmp) + return false; + // If BB1 is actually on the false edge of the conditional branch, remember // to swap the select operands later. bool Invert = false; @@ -1029,8 +1035,7 @@ static bool SpeculativelyExecuteBB(BranchInst *BI, BasicBlock *BB1) { BasicBlock::iterator InsertPos = BI; if (InsertPos != BIParent->begin()) --InsertPos; - if (InsertPos->getOpcode() == Instruction::ICmp || - InsertPos->getOpcode() == Instruction::FCmp) + if (InsertPos == BrCond) BIParent->getInstList().splice(InsertPos, BB1->getInstList(), I); else BIParent->getInstList().splice(BI, BB1->getInstList(), I); @@ -1039,10 +1044,10 @@ static bool SpeculativelyExecuteBB(BranchInst *BI, BasicBlock *BB1) { // false value is the previously determined FalseV. SelectInst *SI; if (Invert) - SI = SelectInst::Create(BI->getCondition(), FalseV, I, + SI = SelectInst::Create(BrCond, FalseV, I, FalseV->getName() + "." + I->getName(), BI); else - SI = SelectInst::Create(BI->getCondition(), I, FalseV, + SI = SelectInst::Create(BrCond, I, FalseV, I->getName() + "." + FalseV->getName(), BI); // Make the PHI node use the select for all incoming values for "then" and |