)]}'
{
  "commit": "2de936b6eb38e7a37224a97c2a22aa79b9dfb9dc",
  "tree": "6e183f9c0e53f2f3d6bca16096c01ed3ea277bd0",
  "parents": [
    "e78b763568e47e685926614195c3075afa35668c"
  ],
  "author": {
    "name": "Andrzej Warzyński",
    "email": "andrzej.warzynski@arm.com",
    "time": "Thu Apr 24 18:05:41 2025 +0100"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Thu Apr 24 18:05:41 2025 +0100"
  },
  "message": "[mlir][vector] Fix emulation of \"narrow\" type `vector.store` (#133231)\n\nBelow are two examples of \"narrow\" `vector.stores`. The first example\n  does not require partial stores and hence no RMW stores. This is\n  currently emulated correctly.\n  ```mlir\n  func.func @example_1(%arg0: vector\u003c4xi2\u003e) {\n      %0 \u003d memref.alloc() : memref\u003c13xi2\u003e\n      %c4 \u003d arith.constant 4 : index\n      vector.store %arg0, %0[%c4] : memref\u003c13xi2\u003e, vector\u003c4xi2\u003e\n      return\n  }\n  ```\n\n  The second example requires a partial (and hence RMW) store due to the\n  offset pointing outside the emulated type boundary (`%c3`).\n  ```mlir\n  func.func @example_2(%arg0: vector\u003c4xi2\u003e) {\n      %0 \u003d memref.alloc() : memref\u003c13xi2\u003e\n      %c3 \u003d arith.constant 3 : index\n      vector.store %arg0, %0[%c3] : memref\u003c13xi2\u003e, vector\u003c4xi2\u003e\n      return\n  }\n  ```\n\n  This is currently incorrectly emulated as a single \"full\" store (note\n  that the offset is incorrect) instead of partial stores:\n  ```mlir\n  func.func @example_2(%arg0: vector\u003c4xi2\u003e) {\n    %alloc \u003d memref.alloc() : memref\u003c4xi8\u003e\n    %0 \u003d vector.bitcast %arg0 : vector\u003c4xi2\u003e to vector\u003c1xi8\u003e\n    %c0 \u003d arith.constant 0 : index\n    vector.store %0, %alloc[%c0] : memref\u003c4xi8\u003e, vector\u003c1xi8\u003e\n    return\n  }\n  ```\n\n  The incorrect emulation stems from this simplified (i.e. incomplete)\n  calculation of the front padding:\n  ```cpp\n      std::optional\u003cint64_t\u003e foldedNumFrontPadElems \u003d\n          isDivisibleInSize ? 0\n: getConstantIntValue(linearizedInfo.intraDataOffset);\n  ```\n\n  Since `isDivisibleInSize` is `true` (i8 / i2 \u003d 4):\n    * front padding is set to `0` and, as a result,\n    * the input offset (`%c3`) is ignored, and\n    * we incorrectly assume that partial stores won\u0027t be needed.\n\n  Note that in both examples we are storing `vector\u003c4xi2\u003e` into\n  `memref\u003c13xi2\u003e` (note _different_ trailing dims) and hence partial\n  stores might in fact be required. The condition above is updated to:\n  ```cpp\n      std::optional\u003cint64_t\u003e foldedNumFrontPadElems \u003d\n          (isDivisibleInSize \u0026\u0026 trailingDimsMatch)\n              ? 0\n              : getConstantIntValue(linearizedInfo.intraDataOffset);\n  ```\n\n  This change ensures that the input offset is properly taken into\n  account, which fixes the issue. It doesn\u0027t affect `@example1`.\n\n  Additional comments are added to clarify the current logic.",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "8d4dcb2b27bf9c934ffd2e17fc1ad25d9eaa61bd",
      "old_mode": 33188,
      "old_path": "mlir/lib/Dialect/Vector/Transforms/VectorEmulateNarrowType.cpp",
      "new_id": "a560aa1b1e680d6da51605fcb7274b4c04cb7220",
      "new_mode": 33188,
      "new_path": "mlir/lib/Dialect/Vector/Transforms/VectorEmulateNarrowType.cpp"
    },
    {
      "type": "modify",
      "old_id": "6fc974200c6f3995e8bd81c38ae47f612c9eab48",
      "old_mode": 33188,
      "old_path": "mlir/test/Dialect/Vector/vector-emulate-narrow-type-unaligned.mlir",
      "new_id": "21f073efc49b2527b9f86d79388e76a233de9b44",
      "new_mode": 33188,
      "new_path": "mlir/test/Dialect/Vector/vector-emulate-narrow-type-unaligned.mlir"
    },
    {
      "type": "modify",
      "old_id": "9dc3eb6989c6ca5abf56a91ff5262888d3b30fb0",
      "old_mode": 33188,
      "old_path": "mlir/test/Dialect/Vector/vector-emulate-narrow-type.mlir",
      "new_id": "9e2d131f421b7e571518e62e2697552e8d58f272",
      "new_mode": 33188,
      "new_path": "mlir/test/Dialect/Vector/vector-emulate-narrow-type.mlir"
    }
  ]
}
