diff options
author | Teresa Johnson <tejohnson@google.com> | 2019-03-27 18:44:25 +0000 |
---|---|---|
committer | Teresa Johnson <tejohnson@google.com> | 2019-03-27 18:44:25 +0000 |
commit | b7e213808c12967dbf9286d9d566a88a23cd20c3 (patch) | |
tree | fb69b5d5622020b0b3bfa3f774dc7f6ae5cba925 /llvm/lib/CodeGen/CodeGenPrepare.cpp | |
parent | eaf4df47821672d3117409d98dae341ea4e972d2 (diff) | |
download | llvm-b7e213808c12967dbf9286d9d566a88a23cd20c3.zip llvm-b7e213808c12967dbf9286d9d566a88a23cd20c3.tar.gz llvm-b7e213808c12967dbf9286d9d566a88a23cd20c3.tar.bz2 |
[CGP] Reset DT when optimizing select instructions
Summary:
A recent fix (r355751) caused a compile time regression because setting
the ModifiedDT flag in optimizeSelectInst means that each time a select
instruction is optimized the function walk in runOnFunction stops and
restarts again (which was needed to build a new DT before we started
building it lazily in r356937). Now that the DT is built lazily, a
simple fix is to just reset the DT at this point, rather than restarting
the whole function walk.
In the future other places that set ModifiedDT may want to switch to
just resetting the DT directly. But that will require an evaluation to
ensure that they don't otherwise need to restart the function walk.
Reviewers: spatel
Subscribers: jdoerfert, llvm-commits, xur
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59889
llvm-svn: 357111
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r-- | llvm/lib/CodeGen/CodeGenPrepare.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp index 9d642ba..20a9030 100644 --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -362,7 +362,7 @@ class TypePromotionTransaction; bool optimizeExt(Instruction *&I); bool optimizeExtUses(Instruction *I); bool optimizeLoadExt(LoadInst *Load); - bool optimizeSelectInst(SelectInst *SI, bool &ModifiedDT); + bool optimizeSelectInst(SelectInst *SI); bool optimizeShuffleVectorInst(ShuffleVectorInst *SVI); bool optimizeSwitchInst(SwitchInst *SI); bool optimizeExtractElementInst(Instruction *Inst); @@ -5921,7 +5921,7 @@ static Value *getTrueOrFalseValue( /// If we have a SelectInst that will likely profit from branch prediction, /// turn it into a branch. -bool CodeGenPrepare::optimizeSelectInst(SelectInst *SI, bool &ModifiedDT) { +bool CodeGenPrepare::optimizeSelectInst(SelectInst *SI) { // If branch conversion isn't desirable, exit early. if (DisableSelectToBranch || OptSize || !TLI) return false; @@ -5962,7 +5962,11 @@ bool CodeGenPrepare::optimizeSelectInst(SelectInst *SI, bool &ModifiedDT) { !isFormingBranchFromSelectProfitable(TTI, TLI, SI)) return false; - ModifiedDT = true; + // The DominatorTree needs to be rebuilt by any consumers after this + // transformation. We simply reset here rather than setting the ModifiedDT + // flag to avoid restarting the function walk in runOnFunction for each + // select optimized. + DT.reset(); // Transform a sequence like this: // start: @@ -7016,7 +7020,7 @@ bool CodeGenPrepare::optimizeInst(Instruction *I, bool &ModifiedDT) { case Instruction::Call: return optimizeCallInst(cast<CallInst>(I), ModifiedDT); case Instruction::Select: - return optimizeSelectInst(cast<SelectInst>(I), ModifiedDT); + return optimizeSelectInst(cast<SelectInst>(I)); case Instruction::ShuffleVector: return optimizeShuffleVectorInst(cast<ShuffleVectorInst>(I)); case Instruction::Switch: |