[Mlir-commits] [mlir] [mlir][scf] Clamp normalized loop sizes where they are combined (PR #223256)

Aviad Cohen llvmlistbot at llvm.org
Sat Oct 3 21:18:01 PDT 2026


================
@@ -1181,15 +1198,20 @@ void mlir::collapseParallelLoops(
 
   // Normalize ParallelOp's iteration pattern.
   SmallVector<Value, 3> normalizedUpperBounds;
+  SmallVector<Value, 3> normalizedDivisors;
   for (unsigned i = 0, e = loops.getNumLoops(); i < e; ++i) {
     OpBuilder::InsertionGuard g2(rewriter);
     rewriter.setInsertionPoint(loops);
     Value lb = loops.getLowerBound()[i];
     Value ub = loops.getUpperBound()[i];
     Value step = loops.getStep()[i];
     auto newLoopRange = emitNormalizedLoopBounds(rewriter, loc, lb, ub, step);
-    normalizedUpperBounds.push_back(getValueOrCreateConstantIntOp(
-        rewriter, loops.getLoc(), newLoopRange.size));
+    Value size = getValueOrCreateConstantIntOp(rewriter, loops.getLoc(),
+                                               newLoopRange.size);
+    normalizedUpperBounds.push_back(
----------------
AviadCo wrote:

Please see the case in the test I commented, in the UB is dynamic we still put `max(ub, 0)` - I think it is not fully safe 

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


More information about the Mlir-commits mailing list