[llvm] [LoopUnroll][NVPTX] Boost full unroll threshold to enable alloca promotion (PR #184855)
Akshay Deodhar via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 11 18:14:51 PDT 2026
================
@@ -866,9 +866,14 @@ static bool mayHaveLoopDependentAccess(const Loop *L, ScalarEvolution &SE) {
if (!isa<AllocaInst>(UnderlyingObject))
continue;
const SCEV *PtrSCEV = SE.getSCEV(Ptr);
- // Optimistically include LoopVariant because those accesses may still
- // benefit from full unrolling.
- if (SE.getLoopDisposition(PtrSCEV, L) != ScalarEvolution::LoopInvariant)
+ auto PtrLoopDisposition = SE.getLoopDisposition(PtrSCEV, L);
+ if (PtrLoopDisposition == ScalarEvolution::LoopComputable)
+ return true;
+ // For LoopVariant pointers, only boost if the SCEV contains a
+ // recurrence rooted at L. This filters out pointers that are
+ // LoopVariant only because of SCEVUnknowns in nested subloops.
+ if (PtrLoopDisposition == ScalarEvolution::LoopVariant &&
+ SE.containsAddRecurrenceOnLoop(PtrSCEV, L))
----------------
akshayrdeodhar wrote:
It might be interesting to investigate if we can get rid of PtrLoopDisposition alltogether, and use containsAddRecurrenceOnLoop instead? If that is what we're truly looking for?
https://github.com/llvm/llvm-project/pull/184855
More information about the llvm-commits
mailing list