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

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Jun 7 09:34:20 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>(
----------------
MaheshRavishankar wrote:

Actually you can make this
```
OpFoldResult newLowerBound = isZeroBased ? lb : rewriter.getOneAttr(lb.getType());
```

Same for the lower bound and step.

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


More information about the Mlir-commits mailing list