[llvm] [LSR] Don't count conditional loads/store as enabling pre/post-index (PR #159573)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 18 06:51:17 PDT 2025


================
@@ -1647,6 +1659,12 @@ bool LSRFixup::isUseFullyOutsideLoop(const Loop *L) const {
   return !L->contains(UserInst);
 }
 
+/// Test whether this fixup is for an instruction that's unconditional, i.e.
+/// it's executed in every loop iteration.
+bool LSRFixup::isUseUnconditional(const Loop *L) const {
+  return isGuaranteedToExecuteForEveryIteration(UserInst, L);
----------------
nikic wrote:

Hm... what kind of "unconditional" execution do you actually need in this context? There's a hierarchy here:

1. Not inside interior control flow in the loop (your test case).
2. Plus no early exits.
3. Plus no abnormal exits.

I think that at least you don't care about abnormal exits in this context? If there is an instruction that can throw/diverge in the loop, that shouldn't interfere with indexed addressing, right? In that case using isGuaranteedToExecuteForEveryIteration() is both unnecessarily conservative and unnecessarily expensive, as it has to scan for abnormal exits.

https://github.com/llvm/llvm-project/pull/159573


More information about the llvm-commits mailing list