summaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/SimplifyCFG.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2013-01-24 12:05:17 +0000
committerChandler Carruth <chandlerc@gmail.com>2013-01-24 12:05:17 +0000
commit47d8f6dca5a64f642a82d24b9e3cf882b56c5c3e (patch)
tree8fb86bb7c603213b018a7ab3f22f128ffb5820fd /lib/Transforms/Utils/SimplifyCFG.cpp
parent681add7a63b44249fd0fd38e63f10f18d6e99e38 (diff)
downloadllvm-47d8f6dca5a64f642a82d24b9e3cf882b56c5c3e.tar.gz
llvm-47d8f6dca5a64f642a82d24b9e3cf882b56c5c3e.tar.bz2
llvm-47d8f6dca5a64f642a82d24b9e3cf882b56c5c3e.tar.xz
Address a large chunk of this FIXME by accumulating the cost for
unfolded constant expressions rather than checking each one independently. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173341 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r--lib/Transforms/Utils/SimplifyCFG.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp
index 7ec31657ec..11cb25d0f9 100644
--- a/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1446,14 +1446,12 @@ static bool SpeculativelyExecuteBB(BranchInst *BI, BasicBlock *ThenBB) {
if (Operator::getOpcode(CE) == Instruction::Select)
return false;
- // An unfolded ConstantExpr could end up getting expanded into
- // Instructions. Don't speculate this and another instruction at
- // the same time.
- // FIXME: This is strange because provided we haven't already hit the cost
- // of 1, this code will speculate an arbitrary number of complex constant
- // expression PHI nodes. Also, this doesn't account for how complex the
- // constant expression is.
- if (SpeculationCost > 0)
+ // Account for the cost of an unfolded ConstantExpr which could end up
+ // getting expanded into Instructions.
+ // FIXME: This doesn't account for how many operations are combined in the
+ // constant expression.
+ ++SpeculationCost;
+ if (SpeculationCost > 1)
return false;
}