[Mlir-commits] [mlir] [mlir][vector] Fix invalid `LoadOp` indices being created (PR #75519)

Rik Huijzer llvmlistbot at llvm.org
Thu Dec 14 11:36:37 PST 2023


================
@@ -1615,8 +1615,10 @@ GetGlobalOp::verifySymbolUses(SymbolTableCollection &symbolTable) {
 //===----------------------------------------------------------------------===//
 
 LogicalResult LoadOp::verify() {
-  if (getNumOperands() != 1 + getMemRefType().getRank())
-    return emitOpError("incorrect number of indices for load");
+  if (getNumOperands() - 1 != getMemRefType().getRank()) {
+    return emitOpError("incorrect number of indices for load, expected ")
+           << getMemRefType().getRank() << " but got " << getNumOperands() - 1;
+  }
----------------
rikhuijzer wrote:

I moved the `+ 1` to the other side because, for example, `memref.load %1[%arg4]` has `%1` as its first operand and `%arg4` as it's second operand. So the number of indices for `memref.load` is `getNumOperands() - 1`.

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


More information about the Mlir-commits mailing list