[llvm] r354547 - [LoopSimplifyCFG] Add missing MSSA edge deletion
Max Kazantsev via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 20 21:51:29 PST 2019
Author: mkazantsev
Date: Wed Feb 20 21:51:29 2019
New Revision: 354547
URL: http://llvm.org/viewvc/llvm-project?rev=354547&view=rev
Log:
[LoopSimplifyCFG] Add missing MSSA edge deletion
When we create fictive switch in preheader, we should take
care about MSSA and delete edge between old preheader and
header.
Modified:
llvm/trunk/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
llvm/trunk/test/Transforms/LoopSimplifyCFG/lcssa.ll
Modified: llvm/trunk/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopSimplifyCFG.cpp?rev=354547&r1=354546&r2=354547&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopSimplifyCFG.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopSimplifyCFG.cpp Wed Feb 20 21:51:29 2019
@@ -355,6 +355,8 @@ private:
BasicBlock *NewPreheader = Preheader->splitBasicBlock(
Preheader->getTerminator(),
Twine(Preheader->getName()).concat("-split"));
+ if (MSSAU)
+ MSSAU->removeEdge(Preheader, L.getHeader());
DTUpdates.push_back({DominatorTree::Delete, Preheader, L.getHeader()});
DTUpdates.push_back({DominatorTree::Insert, NewPreheader, L.getHeader()});
DTUpdates.push_back({DominatorTree::Insert, Preheader, NewPreheader});
Modified: llvm/trunk/test/Transforms/LoopSimplifyCFG/lcssa.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopSimplifyCFG/lcssa.ll?rev=354547&r1=354546&r2=354547&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LoopSimplifyCFG/lcssa.ll (original)
+++ llvm/trunk/test/Transforms/LoopSimplifyCFG/lcssa.ll Wed Feb 20 21:51:29 2019
@@ -154,3 +154,41 @@ bb8:
bb10: ; preds = %bb2
ret void
}
+
+define void @memlcssa() {
+; CHECK-LABEL: @memlcssa(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: switch i32 0, label [[ENTRY_SPLIT:%.*]] [
+; CHECK-NEXT: i32 1, label [[DEFAULT_BB:%.*]]
+; CHECK-NEXT: ]
+; CHECK: entry-split:
+; CHECK-NEXT: br label [[FOR_BODY:%.*]]
+; CHECK: for.body:
+; CHECK-NEXT: call void @foo()
+; CHECK-NEXT: br label [[FOR_BODY]]
+; CHECK: default.bb:
+; CHECK-NEXT: unreachable
+;
+entry:
+ br label %for.body
+
+for.body: ; preds = %exit, %entry
+ br label %switch.bb
+
+switch.bb: ; preds = %for.body
+ switch i2 1, label %default.bb [
+ i2 1, label %case.bb
+ ]
+
+case.bb: ; preds = %switch
+ br label %exit
+
+default.bb: ; preds = %switch
+ unreachable
+
+exit: ; preds = %case.bb
+ call void @foo()
+ br label %for.body
+}
+
+declare void @foo()
More information about the llvm-commits
mailing list