[Mlir-commits] [mlir] 1f9ca5a - [MLIR] Avoid creation of buggy affine maps while replacing dimension and symbol

Uday Bondhugula llvmlistbot at llvm.org
Fri Nov 19 22:33:21 PST 2021


Author: Arnab Dutta
Date: 2021-11-20T12:01:29+05:30
New Revision: 1f9ca5adbac08dcca73b9e12aa2c5ed777cc460e

URL: https://github.com/llvm/llvm-project/commit/1f9ca5adbac08dcca73b9e12aa2c5ed777cc460e
DIFF: https://github.com/llvm/llvm-project/commit/1f9ca5adbac08dcca73b9e12aa2c5ed777cc460e.diff

LOG: [MLIR] Avoid creation of buggy affine maps while replacing dimension and symbol

Initially before appending the newly composed dimension and symbols
to the dimension and symbol list whose size is to be passed in
AffineMap::get(), the call to the AffineMap::get() was made, resulting
in wrong dimCount and symbolCount being passed as argument. We move the
call to the AffineMap::get() after the diimension and symbol list are
updated.

Differential Revision: https://reviews.llvm.org/D114237

Added: 
    

Modified: 
    mlir/lib/Dialect/Affine/IR/AffineOps.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
index 9f24cfcb714e4..2ca0474d9868a 100644
--- a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
+++ b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
@@ -625,13 +625,13 @@ static LogicalResult replaceDimOrSym(AffineMap *map,
   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();
 }


        


More information about the Mlir-commits mailing list