Skip to content

Commit fa2e9ca

Browse files
authored
[mlir][scf] Fix a div-by-zero bug when step of scf.for is zero
1 parent 79a5974 commit fa2e9ca

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ bool LoopPipelinerInternal::initializeLoopInfo(
119119
int64_t ubImm = upperBoundCst.value();
120120
int64_t lbImm = lowerBoundCst.value();
121121
int64_t stepImm = stepCst.value();
122+
if (stepImm <= 0) {
123+
LDBG("--invalid loop step -> BAIL");
124+
return false;
125+
}
122126
int64_t numIteration = llvm::divideCeilSigned(ubImm - lbImm, stepImm);
123127
if (numIteration > maxStage) {
124128
dynamicLoop = false;

0 commit comments

Comments
 (0)