[llvm] [InstCombine] Canonicalise SextADD + GEP (PR #69581)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 25 20:23:47 PDT 2024
nikic wrote:
Patch for the inbounds preservation: https://github.com/llvm/llvm-project/pull/90160
> @nikic Thanks! When the geps would retain the inbounds property, the loop flatten pass would indeed succeed: https://godbolt.org/z/K64q46ah1 I shortly tried your patch with my C loop as input, but did not get it to retain the inbounds, even when the loop variables are `unsigned`. What is a scenario where you expect `isKnownNonNegative` to be derived?
The problem here is that the IR at the time of the first InstCombine run is in non-rotated form (https://gist.github.com/nikic/e634b018bf63ae01c648516326f89faa). Lateron, we can very easily see that `%n` is non-negative, because there is an explicit condition for it in IR. This early, it's theoretically possible to derive this, but likely isn't feasible for compile-time reasons. So this may be a dead end for this example.
Worth noting that since https://github.com/llvm/llvm-project/pull/78576 LoopFlatten will still apply without inbounds via loop versioning, so this is not a question of whether flattening occurs, just of whether it requires versioning or not.
https://github.com/llvm/llvm-project/pull/69581
More information about the llvm-commits
mailing list