Skip to content

Commit 7e5c24c

Browse files
committed
Bail on negative steps, fix formatting
1 parent c5fe22d commit 7e5c24c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

mlir/lib/Dialect/SCF/Transforms/LoopSpecialization.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,9 @@ static LogicalResult peelForLoop(RewriterBase &b, ForOp forOp,
123123
auto ubInt = getConstantIntValue(forOp.getUpperBound());
124124
auto stepInt = getConstantIntValue(forOp.getStep());
125125

126-
// No specialization necessary if step size is 1. Also bail out in case of a zero step which might have happened during folding.
127-
if (stepInt == static_cast<int64_t>(1) || stepInt == static_cast<int64_t>(0))
126+
// No specialization necessary if step size is 1. Also bail out in case of an
127+
// invalid zero or negative step which might have happened during folding.
128+
if (stepInt && *stepInt <= 1)
128129
return failure();
129130

130131
// No specialization necessary if step already divides upper bound evenly.

0 commit comments

Comments
 (0)