[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:11 PST 2025
================
@@ -625,14 +626,24 @@ static void unifyBitWidth(APInt &A, APInt &B) {
B = B.sext(A.getBitWidth());
}
-Constant *StraightLineStrengthReduce::getIndexDelta(Candidate &C,
- Candidate &Basis) {
- APInt Idx = C.Index->getValue(), BasisIdx = Basis.Index->getValue();
- unifyBitWidth(Idx, BasisIdx);
- APInt IndexDelta = Idx - BasisIdx;
- IntegerType *DeltaType =
- IntegerType::get(C.Ins->getContext(), IndexDelta.getBitWidth());
- return ConstantInt::get(DeltaType, IndexDelta);
+Value *StraightLineStrengthReduce::getDelta(const Candidate &C,
+ const Candidate &Basis,
+ Candidate::DKind K) const {
+ if (K == Candidate::IndexDelta) {
+ APInt Idx = C.Index->getValue(), BasisIdx = Basis.Index->getValue();
----------------
Artem-B wrote:
Nit: multiple initialized variables on the same line are hard to read. Instantiating them separately makes it easier to tell where `BasisIdx` comes from.
https://github.com/llvm/llvm-project/pull/169614
More information about the llvm-commits
mailing list