[PATCH] D140831: Fix a phase-ordering problem in SimplifyCFG.
Owen Anderson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 2 21:00:02 PST 2023
resistor updated this revision to Diff 485914.
resistor added a comment.
Reduce test case.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D140831/new/
https://reviews.llvm.org/D140831
Files:
llvm/lib/Transforms/Utils/Local.cpp
llvm/test/Transforms/SimplifyCFG/switch-simplify-crash2.ll
Index: llvm/test/Transforms/SimplifyCFG/switch-simplify-crash2.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/SimplifyCFG/switch-simplify-crash2.ll
@@ -0,0 +1,27 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S -passes="simplifycfg<forward-switch-cond;no-keep-loops>" < %s | FileCheck %s
+
+define i8 @test() {
+; CHECK-LABEL: @test(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[LOOP2:%.*]]
+; CHECK: loop2:
+; CHECK-NEXT: br label [[LOOP2]]
+;
+entry:
+ br label %loop
+
+loop:
+ %phi1 = phi i8 [ 0, %entry ], [ %phi2, %loop2 ]
+ br label %loop2
+
+loop2:
+ %phi2 = phi i8 [ %phi1, %loop ], [ 0, %loop2 ]
+ switch i8 %phi2, label %loop [
+ i8 0, label %loop2
+ i8 1, label %exit
+ ]
+
+exit:
+ ret i8 0
+}
Index: llvm/lib/Transforms/Utils/Local.cpp
===================================================================
--- llvm/lib/Transforms/Utils/Local.cpp
+++ llvm/lib/Transforms/Utils/Local.cpp
@@ -237,6 +237,8 @@
DefaultDest->removePredecessor(ParentBB);
i = SI->removeCase(i);
e = SI->case_end();
+ // Removing this case may have made the condition constant.
+ CI = dyn_cast<ConstantInt>(SI->getCondition());
Changed = true;
continue;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140831.485914.patch
Type: text/x-patch
Size: 1341 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230103/c95fb65d/attachment.bin>
More information about the llvm-commits
mailing list