[llvm] [IR][JumpThreading] Fix infinite recursion on compare self-reference [updated] (PR #129501)
Michael Kruse via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 25 05:53:42 PDT 2025
Meinersbur wrote:
Values might not just be reused by different icmp instructions, but also by different arguments and/or using different paths:
```llvm
Preheader:
br label %LoopHeader
LoopHeader:
%common_phi = phi i32 [%Preheader, 0], [%Latch, 1]
br label %Latch
Latch:
%phi1 = phi i32 [%LoopHeader, %common_phi]
%phi2 = phi i32 [%LoopHeader, %common_phi]
%cmp = icmp eq %phi1, %phi2
br %cmp, label %LoopHeader, label %Exit
Exit:
```
Assuming that `evaluateOnPredecessorEdge` recurses into all of the PHIs (I dont know the exact exit conditions), on the second visit, `%common_phi` has already been marked as visited. This is reachable code, so this should not happen.
https://github.com/llvm/llvm-project/pull/129501
More information about the llvm-commits
mailing list