)]}'
{
  "commit": "5083e80c14a5c1f0ab40b5df95771ebbdda1adb2",
  "tree": "6edebc090bee7bc4856bc4d34f930cc56e3105c0",
  "parents": [
    "076318bd78f5ed338350841075316a75d89ecd9b"
  ],
  "author": {
    "name": "ivangarcia44",
    "email": "36650061+ivangarcia44@users.noreply.github.com",
    "time": "Wed Apr 09 10:50:16 2025 -0400"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Wed Apr 09 16:50:16 2025 +0200"
  },
  "message": "Folding extract_strided_metadata input into reinterpret_cast (#134845)\n\nWe can always fold the input of a extract_strided_metadata operator to\nthe input of a reinterpret_cast operator, because they point to the same\nmemory. Note that the reinterpret_cast does not use the layout of its\ninput memref, only its base memory pointer which is the same as the base\npointer returned by the extract_strided_metadata operator and the base\npointer of the extract_strided_metadata memref input.\n\nOperations like expand_shape, collapse_shape, and subview are lowered to\na pair of extract_strided_metadata and reinterpret_cast like this:\n      \n%base_buffer, %offset, %sizes:2, %strides:2 \u003d\nmemref.extract_strided_metadata %input_memref :\nmemref\u003cID1x...xIDNxBaseType\u003e -\u003e memref\u003cf32\u003e, index, index, index, index,\nindex\n\n%reinterpret_cast \u003d memref.reinterpret_cast %base_buffer to offset:\n[%o1], sizes: [%d1,...,%dN], strides: [%s1,...,%N] : memref\u003cf32\u003e to\nmemref\u003cOD1x...xODNxBaseType \u003e\n\nIn many cases the input of the extract_strided_metadata input can be\npassed directly into the input of the reinterpret_cast operation like\nthis (see how %base_buffer is replaced by %input_memref in the\nreinterpret_cast above and the input type is updated):\n\n%base_buffer, %offset, %sizes:2, %strides:2 \u003d\nmemref.extract_strided_metadata %input_memref :\nmemref\u003cID1x...xIDNxBaseType\u003e -\u003e memref\u003cf32\u003e, index, index, index, index,\nindex\n%reinterpret_cast \u003d memref.reinterpret_cast %input_memref to offset:\n[%o1], sizes: [%d1,...,%dN], strides: [%s1,...,%N] :\nmemref\u003cID1x...xIDNxBaseType\u003e to memref\u003cOD1x...xODNxBaseType \u003e\n\nWhen dealing with static dimensions, the extract_strided_metatdata will\nbecome deadcode and we end up only with a reinterpret_cast:\n\n%reinterpret_cast \u003d memref.reinterpret_cast %input_memref to offset:\n[%o1], sizes: [%d1,...,%dN], strides: [%s1,...,%N] :\nmemref\u003cID1x...xIDNxBaseType\u003e to memref\u003cOD1x...xODNxBaseType \u003e\n\nNote that reinterpret_cast only reads the base memory pointer from the\ninput memref (%input_memref above), which is equivalent to the\n%base_buffer returned by the extract_strided_metadata operation. Hence\nit is legal always to use the extract_strided_metadata input memref\ndirectly in the reinterpret_cast. Note that since this is a pointer,\nthis operation is legal even when the base pointer values are modified\nbetween the operation pair.\n\n@matthias-springer \n@joker-eph \n@sahas3\n@Hanumanth04\n@dixinzhou\n@rafaelubalmw\n\n---------\n\nCo-authored-by: Ivan Garcia \u003cigarcia@vdi-ah2ddp-178.dhcp.mathworks.com\u003e",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "123666848f83ac7adf4bf6b4fdeed997ede8c9ca",
      "old_mode": 33188,
      "old_path": "mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp",
      "new_id": "63f52513987167f1387986de8b6524491cc85e24",
      "new_mode": 33188,
      "new_path": "mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp"
    },
    {
      "type": "modify",
      "old_id": "5d8a7d3f64e8f60768dba52acc9a1c58738554bc",
      "old_mode": 33188,
      "old_path": "mlir/test/Dialect/MemRef/canonicalize.mlir",
      "new_id": "e7cee7cd85426a0530308bf3619ebd16d00d6c34",
      "new_mode": 33188,
      "new_path": "mlir/test/Dialect/MemRef/canonicalize.mlir"
    }
  ]
}
