[llvm] [IR][JumpThreading] Fix infinite recursion on compare self-reference [updated] (PR #129501)
Robert Imschweiler via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 25 06:27:00 PDT 2025
ro-i wrote:
But `evaluateOnPredecessorEdge` recurses only into `CmpInst`s if I'm not mistaken?
When I run your example:
```
define void @foo() {
Preheader:
br label %LoopHeader
LoopHeader:
%common_phi = phi i32 [0, %Preheader], [%phi1, %Latch]
br label %Latch
Latch:
%phi1 = phi i32 [%common_phi, %LoopHeader]
%phi2 = phi i32 [%common_phi, %LoopHeader]
%cmp = icmp eq i32 %phi1, %phi2
br i1 %cmp, label %LoopHeader, label %Exit
Exit:
ret void
}
```
I get:
```
define void @foo() {
Preheader:
br label %Latch
Latch: ; preds = %Preheader, %Latch
%common_phi = phi i32 [ 0, %Preheader ], [ %common_phi, %Latch ]
%cmp = icmp eq i32 %common_phi, %common_phi
br i1 %cmp, label %Latch, label %Exit
Exit: ; preds = %Latch
ret void
}
```
which should be what you intended?
https://github.com/llvm/llvm-project/pull/129501
More information about the llvm-commits
mailing list