[llvm-branch-commits] [llvm] [LoopInterchange] Fix instorder profitability check (PR #181991)
Ryotaro Kasuga via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Feb 20 06:21:23 PST 2026
================
----------------
kasuga-fj wrote:
The primary problem with the current implementation is that it assumes the number of operands in a GEP reflects the dimensionality of the array. As a result, in the following snippet, the current implementation can handle the former case, but not the latter:
```llvm
; Can handle this. The heuristic recognizes this something like `%A[%j][%i]`.
%gep = getelementptr [100 x i8], ptr %A, i64 %j, i64 %i
; Cannot handle this. The heuristic recognizes this something like `%A[100*%j + %i]`.
%mul = mul i64 100, %j
%add = add i64 %mul, %i
%gep = getelementptr [100 x i8], ptr %A, i64 %add
```
As a result, this heuristic often yields strange results. Probably the recent trend of LLVM (a single GEP -> multiple splitted GEPs) exposes this problem more often.
This change makes the heuristic more robust by stopping relying on GEPs so that it can handle the latter case as well.
https://github.com/llvm/llvm-project/pull/181991
More information about the llvm-branch-commits
mailing list