)]}'
{
  "commit": "ac5c687320c3c19a0fe140b4f1c199abe51af2ae",
  "tree": "12dbfa419ffb424aafd82cb11519d4e215a254b0",
  "parents": [
    "d6a1fe04e7cec6b378ecbf6c5b8ee36dd918d5d2"
  ],
  "author": {
    "name": "Jakub Jelinek",
    "email": "jakub@redhat.com",
    "time": "Wed Jul 29 10:15:11 2026 +0200"
  },
  "committer": {
    "name": "Jakub Jelinek",
    "email": "jakub@gcc.gnu.org",
    "time": "Wed Jul 29 10:28:42 2026 +0200"
  },
  "message": "i386: Fix ICE on out of bounds vector elt access [PR126446]\n\nThe following testcase ICEs on x86_64.\nThe isel pass has a check for out of bounds constant index before\noptimizing into .VEC_SET, but it does it using\n      // if index is a constant, then check the bounds\n      poly_uint64 idx_poly;\n      if (poly_int_tree_p (idx, \u0026idx_poly))\n        {\n          poly_uint64 nelts \u003d TYPE_VECTOR_SUBPARTS (TREE_TYPE (view_op0));\n          if (known_gt (idx_poly, nelts))\n            return false;\n        }\nIn the testcase below, idx is INTEGER_CST with long long type and\nnegative value, that doesn\u0027t fit into poly_uint64, so we happily convert\nit into .VEC_SET.\n\nAnd another problem is that the x86 backend isn\u0027t trying to be careful\nand handle out of bounds elt gracefully (I think it could still in theory\nhappen, if GIMPLE lets it through but e.g. something during expansion\nfigures out the index is constant or whatever).\n\nThe following patch fixes it in the backend to avoid triggering UB at compile\ntime by doing HOST_WIDE_INT_1U \u003c\u003c elt etc. when elt is negative or too\nlarge.  In order to avoid ICE, we need to emit something, so I emit\na no-op move, out of bounds vector set shouldn\u0027t change anything in\nthe target.\n\ngimple-isel.cc will be changed incrementally.\n\n2026-07-29  Jakub Jelinek  \u003cjakub@redhat.com\u003e\n\n\tPR target/126446\n\t* config/i386/i386-expand.cc (ix86_expand_vector_set): If elt is\n\tout of bounds, emit a no-op move.\n\n\t* gcc.target/i386/avx2-pr126446.c: New test.\n\nReviewed-by: Uros Bizjak \u003cubizjak@gmail.com\u003e\n(cherry picked from commit 1bc2fdc4f4cbe1b68237f49f211473c56d8a44a3)\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "b4763c703473784bb31343a715a1d8013c7dad45",
      "old_mode": 33188,
      "old_path": "gcc/config/i386/i386-expand.cc",
      "new_id": "be6aed2bd214baf39047b752f1b947c4c46c44bc",
      "new_mode": 33188,
      "new_path": "gcc/config/i386/i386-expand.cc"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "4af8cfd283c7fa7a1932da2faad91b2cebb8dc22",
      "new_mode": 33188,
      "new_path": "gcc/testsuite/gcc.target/i386/avx2-pr126446.c"
    }
  ]
}
