Skip to content

Commit 2d78f1f

Browse files
mrdaybirdhiraditya
authored andcommitted
Add negative rhs stride condition
1 parent 60c1744 commit 2d78f1f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

llvm/lib/Analysis/ScalarEvolution.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13023,8 +13023,11 @@ ScalarEvolution::howManyLessThans(const SCEV *LHS, const SCEV *RHS,
1302313023
// backedge count as:
1302413024
// RHSStart >= Start ? (RHSStart - Start)/(Stride - RHSStride) ? 0
1302513025

13026-
// check if Stride-RHSStride will not overflow
13027-
if (willNotOverflow(llvm::Instruction::Sub, true, Stride, RHSStride)) {
13026+
// check if RHSStride<0 and Stride-RHSStride will not overflow
13027+
// FIXME: Can RHSStride be positive?
13028+
if (isKnownNegative(RHSStride) &&
13029+
willNotOverflow(llvm::Instruction::Sub, true, Stride, RHSStride)) {
13030+
1302813031
const SCEV *Denominator = getMinusSCEV(Stride, RHSStride);
1302913032
if (isKnownPositive(Denominator)) {
1303013033
End = IsSigned ? getSMaxExpr(RHSStart, Start) :

0 commit comments

Comments
 (0)