[Mlir-commits] [mlir] [SCF] Fixed epilogue predicates in loop pipelining (PR #108964)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Sep 17 06:31:01 PDT 2024
================
@@ -671,9 +674,9 @@ LoopPipelinerInternal::emitEpilogue(RewriterBase &rewriter,
setValueMapping(forOp.getInductionVar(), newlastIter, maxStage - i);
if (dynamicLoop) {
- // pred = iterI >= lb
+ // pred = iterI < 0
predicates[i + 1] = rewriter.create<arith::CmpIOp>(
- loc, arith::CmpIPredicate::sge, iterI, lb);
+ loc, arith::CmpIPredicate::slt, iterI, zero);
----------------
sjw36 wrote:
Ah, that's right.
So for:
```
scf.for (lb=3..ub=4, step=2) max_stage = 2
```
This computes:
```
total_iterations = (4 - 3) + 2 - 1 / 2 = 1
iterI(0) = total_iterations - 1 - 0 = 0
newlastIter(0) = iterI(0) * 2 + 3 = 3
pred(0) = iterI(0) >= 0 = true
iterI(1) = total_iterations - 1 - 1 = -1
newlastIter(1) = iterI(1) * 2 + 3 = 1
pred(1) = iterI(1) >= 0 = false
```
I'll update now.
https://github.com/llvm/llvm-project/pull/108964
More information about the Mlir-commits
mailing list