[llvm] [LAA] Avoid stray predicates from replaceSymStrides (PR #216350)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 1 07:53:27 PDT 2026
================
@@ -168,11 +168,18 @@ llvm::replaceSymbolicStrideSCEV(PredicatedScalarEvolution &PSE,
ScalarEvolution *SE = PSE.getSE();
const SCEV *CT = SE->getOne(StrideSCEV->getType());
- PSE.addPredicate(*SE->getEqualPredicate(StrideSCEV, CT));
- const SCEV *Expr = PSE.getSCEV(Ptr);
-
- LLVM_DEBUG(dbgs() << "LAA: Replacing SCEV: " << *OrigSCEV
- << " by: " << *Expr << "\n");
+ const SCEV *Expr;
+ const SCEVPredicate *EqPred = SE->getEqualPredicate(StrideSCEV, CT);
+ if (Predicates) {
+ Predicates->push_back(EqPred);
+ Expr = SE->rewriteUsingPredicate(SE->getSCEV(Ptr), Lp,
+ SCEVUnionPredicate(*Predicates, *SE));
+ } else {
+ PSE.addPredicate(*EqPred);
+ Expr = PSE.getSCEV(Ptr);
+ }
----------------
artagnon wrote:
Agreed, and yes: this is the only place where Predicates == nullptr does not mean "do not add assumptions" :( I think we should avoid the unnecessary assert and keep it as-is for the moment: I believe a later C++ standard would add compile-time constraints, which would have been ideal here?
https://github.com/llvm/llvm-project/pull/216350
More information about the llvm-commits
mailing list