[llvm] 1bf8ae1 - [SimpleLoopUnswitch] Forget loops before invalidating IR.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 1 07:07:17 PST 2023
Author: Florian Hahn
Date: 2023-03-01T16:06:34+01:00
New Revision: 1bf8ae17f5e2714c8c87978fd2042896af3cd46d
URL: https://github.com/llvm/llvm-project/commit/1bf8ae17f5e2714c8c87978fd2042896af3cd46d
DIFF: https://github.com/llvm/llvm-project/commit/1bf8ae17f5e2714c8c87978fd2042896af3cd46d.diff
LOG: [SimpleLoopUnswitch] Forget loops before invalidating IR.
Invalidate SCEV before adjusting switch instruction, so the IR remains
in a valid state for SCEV invalidation.
Added:
Modified:
llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
index 5cccc2b276e8..40ea343cfa24 100644
--- a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
+++ b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
@@ -791,15 +791,25 @@ static bool unswitchTrivialSwitch(Loop &L, SwitchInst &SI, DominatorTree &DT,
Loop *OuterL = &L;
if (DefaultExitBB) {
- // Clear out the default destination temporarily to allow accurate
- // predecessor lists to be examined below.
- SI.setDefaultDest(nullptr);
// Check the loop containing this exit.
Loop *ExitL = LI.getLoopFor(DefaultExitBB);
if (!ExitL || ExitL->contains(OuterL))
OuterL = ExitL;
}
+ if (SE) {
+ if (OuterL)
+ SE->forgetLoop(OuterL);
+ else
+ SE->forgetTopmostLoop(&L);
+ }
+
+ if (DefaultExitBB) {
+ // Clear out the default destination temporarily to allow accurate
+ // predecessor lists to be examined below.
+ SI.setDefaultDest(nullptr);
+ }
+
// Store the exit cases into a separate data structure and remove them from
// the switch.
SmallVector<std::tuple<ConstantInt *, BasicBlock *,
@@ -822,13 +832,6 @@ static bool unswitchTrivialSwitch(Loop &L, SwitchInst &SI, DominatorTree &DT,
SIW.removeCase(CaseI);
}
- if (SE) {
- if (OuterL)
- SE->forgetLoop(OuterL);
- else
- SE->forgetTopmostLoop(&L);
- }
-
// Check if after this all of the remaining cases point at the same
// successor.
BasicBlock *CommonSuccBB = nullptr;
More information about the llvm-commits
mailing list