[all-commits] [llvm/llvm-project] 48686f: [LoopInterchange] Do not interchange guarded imper...
Madhur Amilkanthwar via All-commits
all-commits at lists.llvm.org
Thu Jun 4 23:03:59 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 48686f88f06f358145e4f177dd7c6b3ba1f93ae5
https://github.com/llvm/llvm-project/commit/48686f88f06f358145e4f177dd7c6b3ba1f93ae5
Author: Madhur Amilkanthwar <madhura at nvidia.com>
Date: 2026-06-05 (Fri, 05 Jun 2026)
Changed paths:
M llvm/lib/Transforms/Scalar/LoopInterchange.cpp
M llvm/test/Transforms/LoopInterchange/currentLimitation.ll
A llvm/test/Transforms/LoopInterchange/guarded-inner-loop.ll
M llvm/test/Transforms/LoopInterchange/lcssa-preheader.ll
M llvm/test/Transforms/LoopInterchange/loop-interchange-optimization-remarks.ll
Log Message:
-----------
[LoopInterchange] Do not interchange guarded imperfect loop nests (#201504)
When the outer-loop header conditionally branches to the outer latch,
that branch guards the inner loop, so the inner loop runs only on a
subset of the outer iterations. Interchanging such a nest moves the
inner loop outside the guard and runs it on every outer iteration,
including the guarded-off ones. That is incorrect when the inner loop
relies on the guard to terminate (e.g. an eq/ne exit whose trip count is
degenerate once the guard is false): the extra runs do not terminate, so
the program hangs at run time. Reject these guarded, imperfect nests in
tightlyNested().
This patch takes conservative approach to fix the crash and keep
upstream sane. In the long term, we need to see permissible cases under
which we can still interchange. I believe this is first good step.
Most importantly, three existing tests
(`currentLimitation.ll`, `loop-interchange-optimization-remarks.ll`,
`lcssa-preheader.ll`) were going through this unsafe transform; **these
tests would no longer interchange with this patch.**
I verified that they were hanging after illegal loop interchange with
`lli`: the un-interchanged function returns but the interchanged one
spins for a degenerate input (interchange_01(0, 2), test02(0, 2),
lcssa_08(1, 0)).
Fixes #201273
Assisted by Cursor.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list