[llvm] [Utils] Fix incorrect LCSSA PHI nodes when splitting critical edges with MergeIdenticalEdges (PR #131744)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 19 09:12:25 PDT 2025
================
@@ -438,6 +438,63 @@ define void @crit_edge(i1 %cond0, i1 %cond1) {
EXPECT_TRUE(PDT.verify());
}
+TEST(BasicBlockUtils, SplitLoopCriticalEdge) {
+ LLVMContext C;
+ std::unique_ptr<Module> M = parseIR(C, R"IR(
+declare dso_local i1 @predicate(ptr noundef %p)
+
+define dso_local ptr @Parse(ptr noundef %gp) {
+entry:
+ br label %for.inc
+
+for.inc:
+ %phi = phi ptr [ %gp, %entry ], [ %cp, %while.cond ], [ %cp, %while.cond ]
+ %cond = call i1 @predicate(ptr noundef %phi)
+ %inc= getelementptr inbounds i8, ptr %phi, i64 1
+ br i1 %cond, label %while.cond, label %exit
+
+while.cond:
+ %cp = phi ptr [ %inc, %for.inc ], [ %incdec, %while.body ]
+ %val = load i8, ptr %cp, align 1
+ switch i8 %val, label %while.body [
+ i8 10, label %for.inc
+ i8 0, label %for.inc
+ ]
+
+while.body:
+ %incdec= getelementptr inbounds i8, ptr %cp, i64 1
----------------
nikic wrote:
```suggestion
%incdec = getelementptr inbounds i8, ptr %cp, i64 1
```
https://github.com/llvm/llvm-project/pull/131744
More information about the llvm-commits
mailing list