)]}'
{
  "commit": "1728c1d40ac2bdd84b4dd1c9a7e6da4381f2400a",
  "tree": "8ee4e7b9baa29a2b70159902be4c1341959c71b5",
  "parents": [
    "9abacb34a5726d6cb40e798de48bc4f02b92808b"
  ],
  "author": {
    "name": "Nathan Gauër",
    "email": "brioche@google.com",
    "time": "Tue Aug 16 16:05:47 2022 +0200"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Tue Aug 16 16:05:47 2022 +0200"
  },
  "message": "spirv-opt: fix copy-propagate-arrays index opti on structs. (#4891)\n\n* spirv-opt: fix copy-propagate-arrays index opti on structs.\r\n\r\nAs per SPIR-V spec:\r\nOpAccessChain indices must be OpConstant when indexing into a structure.\r\n\r\nThis optimization tried to remove load cascade. But in some scenario\r\nfailed:\r\n\r\n```c\r\ncbuffer MyStruct {\r\n    uint my_field;\r\n};\r\n\r\nuint main(uint index) {\r\n    const uint my_array[1] \u003d { my_field };\r\n    return my_array[index]\r\n}\r\n```\r\n\r\nThis is valid as the struct is indexed with a constant index, and then\r\nthe array is indexed using a dynamic index.\r\nThe optimization would consider the local array to be useless and\r\ngenerated a load directly into the struct.\r\n\r\n* spirv-opt: prevent creation of unused instructions\r\n\r\nCopy-propagate-arrays optimization pass would create unused constants,\r\neven if the optimization not completed.\r\nThis was caused by the way we handled OpAccessChain squashing: we\r\nonly referenced constants, and had to create them upfront.\r\n\r\nFixes #4887\r\nSigned-off-by: Nathan Gauër \u003cbrioche@google.com\u003e",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "1c30138eb5eb2e395df704df2489bf8e9f051513",
      "old_mode": 33188,
      "old_path": "source/opt/copy_prop_arrays.cpp",
      "new_id": "0b235629bfdaa56cb3ba97fecc3acfc6a27ae6de",
      "new_mode": 33188,
      "new_path": "source/opt/copy_prop_arrays.cpp"
    },
    {
      "type": "modify",
      "old_id": "07747c109b46606ef7c03d10fedd9fdce78ed680",
      "old_mode": 33188,
      "old_path": "source/opt/copy_prop_arrays.h",
      "new_id": "9e7641f6157896ab9b22bb80e43b48960529ba68",
      "new_mode": 33188,
      "new_path": "source/opt/copy_prop_arrays.h"
    },
    {
      "type": "modify",
      "old_id": "f322f4ad3f470bd0e588267182f1a9557d26a327",
      "old_mode": 33188,
      "old_path": "test/opt/copy_prop_array_test.cpp",
      "new_id": "d6e376ecc776f2cd23577a0411bc7aad1d5d0d95",
      "new_mode": 33188,
      "new_path": "test/opt/copy_prop_array_test.cpp"
    }
  ]
}
