[Mlir-commits] [mlir] [mlir][scf]: Avoid using wrong calculation loop pipelining kernel upperbound (PR #116748)

Aviad Cohen llvmlistbot at llvm.org
Mon Nov 18 23:47:04 PST 2024


================
@@ -444,7 +444,15 @@ scf::ForOp LoopPipelinerInternal::createKernelLoop(
         loc, rewriter.getIntegerAttr(t, maxStage));
     Value maxStageByStep =
         rewriter.create<arith::MulIOp>(loc, step, maxStageValue);
-    newUb = rewriter.create<arith::SubIOp>(loc, ub, maxStageByStep);
+    Value hasAtLeastOneIteration = rewriter.create<arith::CmpIOp>(
+        loc, arith::CmpIPredicate::slt, maxStageByStep, ub);
----------------
AviadCo wrote:

Actualy what we want to make sure is that `maxStageByStep < ub`, because if those value are from `unsigned` or `index` may lead to wrong answer. Please see full answer in the second thread.

https://github.com/llvm/llvm-project/pull/116748


More information about the Mlir-commits mailing list