[llvm] [LSR][term-fold] Ensure the simple recurrence is reachable from the current loop (PR #83085)
Patrick O'Neill via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 4 13:44:18 PST 2024
================
@@ -6808,6 +6808,12 @@ canFoldTermCondOfLoop(Loop *L, ScalarEvolution &SE, DominatorTree &DT,
if (!matchSimpleRecurrence(LHS, ToFold, ToFoldStart, ToFoldStep))
return std::nullopt;
+ // If ToFold does not have an incoming value from LoopLatch then the simple
+ // recurrence is from a prior loop unreachable from the loop we're currently
+ // considering.
+ if (ToFold->getBasicBlockIndex(LoopLatch) == -1)
----------------
patrick-rivos wrote:
Updated.
Previously I had tried comparing with the LoopLatch which interfered with the SeveralLoopLatch testcase. I'm going to read up on how getHeader differs from LoopLatch. Thanks!
https://github.com/llvm/llvm-project/pull/83085
More information about the llvm-commits
mailing list