[Mlir-commits] [mlir] [mlir][scf]: Expose emitNormalizedLoopBounds/denormalizeInductionVariable util functions (NFC) (PR #94429)

Aviad Cohen llvmlistbot at llvm.org
Sat Jun 8 23:11:39 PDT 2024


================
@@ -501,26 +483,27 @@ static LoopParams emitNormalizedLoopBounds(RewriterBase &rewriter, Location loc,
   if (isZeroBased && isStepOne)
     return {lb, ub, step};
 
-  Value diff = isZeroBased ? ub : rewriter.create<arith::SubIOp>(loc, ub, lb);
+  Value diff =
+      isZeroBased ? ub : rewriter.createOrFold<arith::SubIOp>(loc, ub, lb);
   Value newUpperBound =
-      isStepOne ? diff : rewriter.create<arith::CeilDivSIOp>(loc, diff, step);
+      isStepOne ? diff
+                : rewriter.createOrFold<arith::CeilDivSIOp>(loc, diff, step);
 
   Value newLowerBound = isZeroBased
                             ? lb
-                            : rewriter.create<arith::ConstantOp>(
+                            : rewriter.createOrFold<arith::ConstantOp>(
----------------
AviadCo wrote:

I added new function called `getValueOrCreateConstantOp` so the bounds type will be maintains during the normalization

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


More information about the Mlir-commits mailing list