diff options
author | Duncan Sands <baldrick@free.fr> | 2010-11-18 19:59:41 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2010-11-18 19:59:41 +0000 |
commit | d0c6f3dafd7c3e9137d4e6415014c94137fcd3fc (patch) | |
tree | 99b6f88540f7b3c4a552911c4020f9e8a42ab9eb /lib/Transforms/Scalar/LoopUnswitch.cpp | |
parent | 707120047e0107cb15dd4bbb31613df129b13c7a (diff) | |
download | external_llvm-d0c6f3dafd7c3e9137d4e6415014c94137fcd3fc.zip external_llvm-d0c6f3dafd7c3e9137d4e6415014c94137fcd3fc.tar.gz external_llvm-d0c6f3dafd7c3e9137d4e6415014c94137fcd3fc.tar.bz2 |
Factor code for testing whether replacing one value with another
preserves LCSSA form out of ScalarEvolution and into the LoopInfo
class. Use it to check that SimplifyInstruction simplifications
are not breaking LCSSA form. Fixes PR8622.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119727 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/LoopUnswitch.cpp')
-rw-r--r-- | lib/Transforms/Scalar/LoopUnswitch.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/Transforms/Scalar/LoopUnswitch.cpp b/lib/Transforms/Scalar/LoopUnswitch.cpp index 009ee7b..2eaeb43 100644 --- a/lib/Transforms/Scalar/LoopUnswitch.cpp +++ b/lib/Transforms/Scalar/LoopUnswitch.cpp @@ -990,15 +990,16 @@ void LoopUnswitch::SimplifyCode(std::vector<Instruction*> &Worklist, Loop *L) { ++NumSimplify; continue; } - + // See if instruction simplification can hack this up. This is common for // things like "select false, X, Y" after unswitching made the condition be // 'false'. - if (Value *V = SimplifyInstruction(I, 0, DT)) { - ReplaceUsesOfWith(I, V, Worklist, L, LPM); - continue; - } - + if (Value *V = SimplifyInstruction(I, 0, DT)) + if (LI->replacementPreservesLCSSAForm(I, V)) { + ReplaceUsesOfWith(I, V, Worklist, L, LPM); + continue; + } + // Special case hacks that appear commonly in unswitched code. if (BranchInst *BI = dyn_cast<BranchInst>(I)) { if (BI->isUnconditional()) { |