[Mlir-commits] [mlir] [mlir][affine] Add fold logic when the affine.yield has IV as operand in the AffineForEmptyLoopFolder (PR #164064)
Jakub Kuderski
llvmlistbot at llvm.org
Sat Oct 18 05:01:48 PDT 2025
================
@@ -2632,8 +2645,15 @@ static SmallVector<OpFoldResult> AffineForEmptyLoopFolder(AffineForOp forOp) {
BlockArgument *iterArgIt = llvm::find(iterArgs, val);
// TODO: It should be possible to perform a replacement by computing the
// last value of the IV based on the bounds and the step.
- if (val == forOp.getInductionVar())
- return {};
+ if (val == forOp.getInductionVar()) {
+ OpFoldResult lastTripIv = getConstantInductionVarForLastTrip(forOp);
+ if (lastTripIv) {
+ replacements.push_back(lastTripIv);
+ continue;
+ } else {
----------------
kuhar wrote:
nit: no else after continue
https://github.com/llvm/llvm-project/pull/164064
More information about the Mlir-commits
mailing list