[llvm] Reland "Redesign Straight-Line Strength Reduction (SLSR) (#162930)" (PR #169614)
Artem Belevich via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 26 12:20:31 PST 2025
================
@@ -677,61 +688,37 @@ void StraightLineStrengthReduce::setBasisAndDeltaFor(Candidate &C) {
return false;
};
- // Priority:
- // Constant Delta from Index > Constant Delta from Base >
- // Constant Delta from Stride > Variable Delta from Base or Stride
- // TODO: Change the priority to align with the cost model.
-
- // First, look for a constant index-diff basis
- if (const auto *IndexDeltaCandidates =
- CandidateDict.getCandidatesWithDeltaKind(C, Candidate::IndexDelta)) {
- bool FoundConstDelta =
- SearchFrom(*IndexDeltaCandidates, [&DT = DT, &C](Candidate *Basis) {
- if (isSimilar(C, *Basis, Candidate::IndexDelta)) {
- assert(DT->dominates(Basis->Ins, C.Ins));
- auto *Delta = getIndexDelta(C, *Basis);
- if (!C.isProfitableRewrite(Delta, Candidate::IndexDelta))
- return false;
- C.Basis = Basis;
- C.DeltaKind = Candidate::IndexDelta;
- C.Delta = Delta;
- LLVM_DEBUG(dbgs() << "Found delta from Index " << *C.Delta << "\n");
- return true;
- }
- return false;
- });
- if (FoundConstDelta)
- return;
- }
-
- // No constant-index-diff basis found. look for the best possible base-diff
- // or stride-diff basis
- // Base/Stride diffs not supported for form (B + i) * S
- if (C.CandidateKind == Candidate::Mul)
- return;
-
auto For = [this, &C](Candidate::DKind K) {
// return true if find a Basis with constant delta and stop searching,
// return false if did not find a Basis or the delta is not a constant
// and continue searching for a Basis with constant delta
----------------
Artem-B wrote:
Nit: Outside of the returned lambda, the comment misses "return a lambda predicate that...".
Alternatively, moving the comments inside of the inner lambda would work, too.
https://github.com/llvm/llvm-project/pull/169614
More information about the llvm-commits
mailing list