summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorAlina Sbirlea <asbirlea@google.com>2018-08-28 20:41:05 +0000
committerAlina Sbirlea <asbirlea@google.com>2018-08-28 20:41:05 +0000
commit52e97a28d47bf50364bef55cc6a1119c8364f0b5 (patch)
tree0c56d4370cfb0a90061ffa72f76ef8a1115a0263 /llvm/lib/Transforms
parent37a66413c107373b52714ace3e9548f929f23539 (diff)
downloadbcm5719-llvm-52e97a28d47bf50364bef55cc6a1119c8364f0b5.tar.gz
bcm5719-llvm-52e97a28d47bf50364bef55cc6a1119c8364f0b5.zip
[SimpleLoopUnswitch] Form dedicated exits after trivial unswitches.
Summary: Form dedicated exits after trivial unswitches. Fixes PR38737, PR38283. Reviewers: chandlerc, fedor.sergeev Subscribers: sanjoy, jlebar, uabelho, llvm-commits Differential Revision: https://reviews.llvm.org/D51375 llvm-svn: 340871
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
index 5834b619046..8b67c470a35 100644
--- a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
+++ b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
@@ -302,10 +302,11 @@ static void hoistLoopToNewParent(Loop &L, BasicBlock &Preheader,
formLCSSA(*OldContainingL, DT, &LI, nullptr);
// We shouldn't need to form dedicated exits because the exit introduced
- // here is the (just split by unswitching) preheader. As such, it is
- // necessarily dedicated.
- assert(OldContainingL->hasDedicatedExits() &&
- "Unexpected predecessor of hoisted loop preheader!");
+ // here is the (just split by unswitching) preheader. However, after trivial
+ // unswitching it is possible to get new non-dedicated exits out of parent
+ // loop so let's conservatively form dedicated exit blocks and figure out
+ // if we can optimize later.
+ formDedicatedExitBlocks(OldContainingL, &DT, &LI, /*PreserveLCSSA*/ true);
}
}
@@ -482,6 +483,7 @@ static bool unswitchTrivialBranch(Loop &L, BranchInst &BI, DominatorTree &DT,
if (FullUnswitch)
hoistLoopToNewParent(L, *NewPH, DT, LI);
+ LLVM_DEBUG(dbgs() << " done: unswitching trivial branch...\n");
++NumTrivial;
++NumBranches;
return true;
@@ -539,7 +541,7 @@ static bool unswitchTrivialSwitch(Loop &L, SwitchInst &SI, DominatorTree &DT,
else if (ExitCaseIndices.empty())
return false;
- LLVM_DEBUG(dbgs() << " unswitching trivial cases...\n");
+ LLVM_DEBUG(dbgs() << " unswitching trivial switch...\n");
// We may need to invalidate SCEVs for the outermost loop reached by any of
// the exits.
@@ -739,6 +741,7 @@ static bool unswitchTrivialSwitch(Loop &L, SwitchInst &SI, DominatorTree &DT,
++NumTrivial;
++NumSwitches;
+ LLVM_DEBUG(dbgs() << " done: unswitching trivial switch...\n");
return true;
}
OpenPOWER on IntegriCloud