[llvm] Redesign Straight-Line Strength Reduction (SLSR) (PR #162930)
Drew Kersnar via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 20 13:43:40 PDT 2025
================
@@ -177,22 +203,164 @@ class StraightLineStrengthReduce {
// Points to the immediate basis of this candidate, or nullptr if we cannot
// find any basis for this candidate.
Candidate *Basis = nullptr;
+
+ DKind DeltaKind = InvalidDelta;
+
+ // Store SCEV of Stride to compute delta from different strides
+ const SCEV *StrideSCEV = nullptr;
+
+ // Points to (Y - X) that will be used to rewrite this candidate.
+ Value *Delta = nullptr;
+
+ /// Cost model: Evaluate the computational efficiency of the candidate.
+ ///
+ /// Efficiency levels (higher is better):
+ /// ZeroInst (5) - [Variable] or [Const]
+ /// OneInstOneVar (4) - [Variable + Const] or [Variable * Const]
+ /// OneInstTwoVar (3) - [Variable + Variable] or [Variable * Variable]
+ /// TwoInstOneVar (2) - [Const + Const * Variable]
+ /// TwoInstTwoVar (1) - [Variable + Const * Variable]
+ enum EfficiencyLevel : unsigned {
+ Unknown = 0,
+ TwoInstTwoVar = 1,
+ TwoInstOneVar = 2,
+ OneInstTwoVar = 3,
+ OneInstOneVar = 4,
+ ZeroInst = 5
+ };
+
+ static EfficiencyLevel
+ getComputationEfficiency(Kind CandidateKind, const ConstantInt *Index,
+ const Value *Stride, const SCEV *Base = nullptr) {
+ bool IsConstantBase = false;
+ bool IsZeroBase = false;
+ // When evaluating the efficiency of a rewrite, if the Basis's SCEV is
----------------
dakersnar wrote:
```suggestion
// When evaluating the efficiency of a rewrite, if the Base's SCEV is
```
Typo, right?
https://github.com/llvm/llvm-project/pull/162930
More information about the llvm-commits
mailing list