[llvm] [LV] Check Addr in getAddressAccessSCEV in terms of SCEV expressions. (PR #171204)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 11 09:08:06 PST 2025
================
@@ -150,6 +152,23 @@ const SCEV *vputils::getSCEVExprForVPValue(const VPValue *V,
.Default([&SE](const VPRecipeBase *) { return SE.getCouldNotCompute(); });
}
+bool vputils::isAddressSCEVForCost(const SCEV *Addr, ScalarEvolution &SE,
+ const Loop *L) {
+ // If address is an SCEVAddExpr, all operands must be either be invariant or a
+ // (possibly sign-extend) affine AddRec.
+ if (auto *PtrAdd = dyn_cast<SCEVAddExpr>(Addr)) {
+ return all_of(PtrAdd->operands(), [&SE, L](const SCEV *Op) {
+ return SE.isLoopInvariant(Op, L) ||
+ match(Op, m_scev_SExt(m_scev_AffineAddRec(m_SCEV(), m_SCEV()))) ||
+ match(Op, m_scev_AffineAddRec(m_SCEV(), m_SCEV()));
+ });
+ }
+
+ // Otherwise, check if address is loop invariant or an affine add recurrence.
+ return SE.isLoopInvariant(Addr, L) ||
+ match(Addr, m_scev_AffineAddRec(m_SCEV(), m_SCEV()));
----------------
david-arm wrote:
Why does the sext of a SCEVAddRecExpr not matter here?
https://github.com/llvm/llvm-project/pull/171204
More information about the llvm-commits
mailing list