Skip to content

Commit e2dbf30

Browse files
committed
Add a comment
1 parent 72efb11 commit e2dbf30

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

llvm/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,13 @@ void StraightLineStrengthReduce::setBasisAndDeltaFor(Candidate &C) {
701701

702702
assert(DT->dominates(Basis->Ins, C.Ins));
703703
Value *Delta = getDelta(C, *Basis, K);
704+
705+
// IndexDelta rewrite is not always profitable, e.g.,
706+
// X = B + 8 * S
707+
// Y = B + S,
708+
// rewriting Y to X - 7 * S is probably a bad idea.
709+
// So, we need to check if the rewrite form's computation efficiency
710+
// is better than the original form.
704711
if (K == Candidate::IndexDelta &&
705712
!C.isProfitableRewrite(Delta, Candidate::IndexDelta))
706713
return false;

0 commit comments

Comments
 (0)