diff --git a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp --- a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp +++ b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp @@ -625,13 +625,13 @@ ValueRange composeSyms = affineApply.getMapOperands().take_back(composeMap.getNumSymbols()); - // Perform the replacement and append the dims and symbols where relevant. + // Append the dims and symbols where relevant and perform the replacement. MLIRContext *ctx = map->getContext(); AffineExpr toReplace = isDimReplacement ? getAffineDimExpr(pos, ctx) : getAffineSymbolExpr(pos, ctx); - *map = map->replace(toReplace, composeExpr, dims.size(), syms.size()); dims.append(composeDims.begin(), composeDims.end()); syms.append(composeSyms.begin(), composeSyms.end()); + *map = map->replace(toReplace, composeExpr, dims.size(), syms.size()); return success(); }