[llvm] 6be1fd6 - [SimplifyCFG] FoldValueComparisonIntoPredecessors(): drop reachable errneous assert
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 7 07:05:41 PST 2021
Author: Roman Lebedev
Date: 2021-01-07T18:05:04+03:00
New Revision: 6be1fd6b20f3418543a50ce9b04ab4a49585a7eb
URL: https://github.com/llvm/llvm-project/commit/6be1fd6b20f3418543a50ce9b04ab4a49585a7eb
DIFF: https://github.com/llvm/llvm-project/commit/6be1fd6b20f3418543a50ce9b04ab4a49585a7eb.diff
LOG: [SimplifyCFG] FoldValueComparisonIntoPredecessors(): drop reachable errneous assert
I have added it in d15d81c because it *seemed* correct, was holding
for all the tests so far, and was validating the fix added in the same
commit, but as David Major is pointing out (with a reproducer),
the assertion isn't really correct after all. So remove it.
Note that the d15d81c still fine.
Added:
llvm/test/Transforms/SimplifyCFG/FoldValueComparisonIntoPredecessors-no-new-successors.ll
Modified:
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 3fbc22a85be4..9aedb918ac32 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1261,7 +1261,6 @@ bool SimplifyCFGOpt::FoldValueComparisonIntoPredecessors(Instruction *TI,
// Okay, at this point, we know which new successor Pred will get. Make
// sure we update the number of entries in the PHI nodes for these
// successors.
- assert(!NewSuccessors.empty() && "Should be adding some new successors.");
for (const std::pair<BasicBlock *, int /*Num*/> &NewSuccessor :
NewSuccessors) {
for (auto I : seq(0, NewSuccessor.second)) {
diff --git a/llvm/test/Transforms/SimplifyCFG/FoldValueComparisonIntoPredecessors-no-new-successors.ll b/llvm/test/Transforms/SimplifyCFG/FoldValueComparisonIntoPredecessors-no-new-successors.ll
new file mode 100644
index 000000000000..03490c9ac34b
--- /dev/null
+++ b/llvm/test/Transforms/SimplifyCFG/FoldValueComparisonIntoPredecessors-no-new-successors.ll
@@ -0,0 +1,35 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S -simplifycfg -simplifycfg-require-and-preserve-domtree=1 < %s | FileCheck %s
+
+define void @widget(i32 %arg) {
+; CHECK-LABEL: @widget(
+; CHECK-NEXT: bb:
+; CHECK-NEXT: [[SWITCH:%.*]] = icmp ult i32 [[ARG:%.*]], 2
+; CHECK-NEXT: br i1 [[SWITCH]], label [[BB2:%.*]], label [[INFLOOP:%.*]]
+; CHECK: bb2:
+; CHECK-NEXT: ret void
+; CHECK: infloop:
+; CHECK-NEXT: br label [[INFLOOP]]
+;
+bb:
+ %tmp = icmp eq i32 %arg, 0
+ br i1 %tmp, label %bb2, label %bb1
+
+bb1: ; preds = %bb1
+ %tmp4 = icmp eq i32 %arg, 1
+ br i1 %tmp4, label %bb6, label %bb5
+
+bb5: ; preds = %bb5, %bb5
+ switch i32 %arg, label %bb5 [
+ i32 0, label %bb9
+ ]
+
+bb2:
+ ret void
+
+bb6: ; preds = %bb1
+ ret void
+
+bb9: ; preds = %bb5
+ ret void
+}
More information about the llvm-commits
mailing list