Skip to content

Commit 3dc98c9

Browse files
committed
Address review comments.
1 parent b1c758c commit 3dc98c9

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

llvm/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ class StraightLineStrengthReduce {
290290
}
291291

292292
// Evaluate if the given delta is profitable to rewrite this candidate.
293-
bool isProfitableRewrite(const Value *Delta, const DKind DeltaKind) const {
293+
bool isProfitableRewrite(const Value &Delta, const DKind DeltaKind) const {
294294
// This function cannot accurately evaluate the profit of whole expression
295295
// with context. A candidate (B + I * S) cannot express whether this
296296
// instruction needs to compute on its own (I * S), which may be shared
@@ -308,22 +308,22 @@ class StraightLineStrengthReduce {
308308

309309
// Evaluate the rewrite efficiency of this candidate with its Basis
310310
EfficiencyLevel getRewriteEfficiency() const {
311-
return Basis ? getRewriteEfficiency(Delta, DeltaKind) : Unknown;
311+
return Basis ? getRewriteEfficiency(*Delta, DeltaKind) : Unknown;
312312
}
313313

314314
// Evaluate the rewrite efficiency of this candidate with a given delta
315-
EfficiencyLevel getRewriteEfficiency(const Value *Delta,
315+
EfficiencyLevel getRewriteEfficiency(const Value &Delta,
316316
const DKind DeltaKind) const {
317317
switch (DeltaKind) {
318318
case BaseDelta: // [X + Delta]
319319
return getComputationEfficiency(
320320
CandidateKind,
321-
ConstantInt::get(cast<IntegerType>(Delta->getType()), 1), Delta);
321+
ConstantInt::get(cast<IntegerType>(Delta.getType()), 1), &Delta);
322322
case StrideDelta: // [X + Index * Delta]
323-
return getComputationEfficiency(CandidateKind, Index, Delta);
323+
return getComputationEfficiency(CandidateKind, Index, &Delta);
324324
case IndexDelta: // [X + Delta * Stride]
325-
return getComputationEfficiency(CandidateKind, cast<ConstantInt>(Delta),
326-
Stride);
325+
return getComputationEfficiency(CandidateKind,
326+
cast<ConstantInt>(&Delta), Stride);
327327
default:
328328
return Unknown;
329329
}
@@ -696,7 +696,7 @@ bool StraightLineStrengthReduce::candidatePredicate(Candidate *Basis,
696696
// So, we need to check if the rewrite form's computation efficiency
697697
// is better than the original form.
698698
if (K == Candidate::IndexDelta &&
699-
!C.isProfitableRewrite(Delta, Candidate::IndexDelta))
699+
!C.isProfitableRewrite(*Delta, Candidate::IndexDelta))
700700
return false;
701701

702702
// If there is a Delta that we can reuse Basis to rewrite C,

llvm/test/Transforms/StraightLineStrengthReduce/slsr-gep.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,9 @@ define void @stride_var(ptr %input, i32 %c, i32 %b, i32 %n, float %r) {
357357
store float %r, ptr %getElem, align 4
358358

359359
%mul = mul nsw i32 %b, %n
360-
%add = add i32 %mul, %c
361-
%add.11 = add i32 %add, %n
362-
%add.2 = add i32 %add.11, %n
360+
%add = add nsw i32 %mul, %c
361+
%add.11 = add nsw i32 %add, %n
362+
%add.2 = add nsw i32 %add.11, %n
363363
%offset1 = sext i32 %add.2 to i64
364364
%getElem.1 = getelementptr inbounds float, ptr %input, i64 %offset1
365365
store float %r, ptr %getElem.1, align 4

0 commit comments

Comments
 (0)