[llvm] [LAA] Avoid stray predicates from replaceSymStrides (PR #216350)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 30 07:52:46 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);
+ }
----------------
fhahn wrote:
Hmm ok I see. The only thing is that in most other places, Predicates == nullptr means do not add assumptions. But I also do not have a much better suggestion.
> and we'd have to document the fact saying "do not pass nullptr here"
Could this be an assert?
https://github.com/llvm/llvm-project/pull/216350
More information about the llvm-commits
mailing list