<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/153012>153012</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [VectorCombine] VectorCombiner goes into infinite loop
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            llvm::vectorcombine
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          redstar
      </td>
    </tr>
</table>

<pre>
    Consider the following IR stored as `bug.ll`:

```
@val = external hidden global ptr, align 8

define void @bug(ptr %ptr1, ptr %ptr2, i64 %idx) #0 {
entry:
  %158 = insertelement <2 x i64> <i64 5, i64 ptrtoint (ptr @val to i64)>, i64 %idx, i32 0
  %159 = or disjoint <2 x i64> splat (i64 2), %158
 store <2 x i64> %159, ptr %ptr2
  ret void
}
```

Feeding this into the vector combiner via `opt --mtriple aarch64-linux -march=neon --passes=vector-combine -debug-only=vector-combine bug.ll -o /dev/null` or `opt --mtriple systemz-linux -march=z13 --passes=vector-combine -debug-only=vector-combine bug.ll -o /dev/null` results in the VectorCombiner going into an infinite loop.

Hang verified with master (ccd35e5b2f1438646d11c27eaa475f34681f9cbe) and llvmorg-21.1.0-rc2.

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy0lEGP4ygQhX8NuZQcQWE79sGHTDLR7nUPe8emYjPCYAHOdM-vX2Gn1er0eSVLUQl47_FVBRWjGR1Rx6ofrLoe1JomH7pAOiYVDr3X793Fu2g0BUgTwd1b638bN8Lf_0BMPpAGFYHVvF_Ho7Ws5kyeGd--mj8_fmYlfygLTF6B3hIFpyxMRmtyMFrfKwtLCgwvoKwZHTS7gqa7cQQPbzSwMlswbJYUgGG1pCDygc8Sc2nqMpdGvzFsgaHkwE4_GD-TS-F9zwZ5h6iaLY5xkUIiSzO5BExeEN6yCpM_c5X1qg_hJYXkTd72jLHfKvntALZM_nzNcAEjEfina7u5-gDaxF-72BfPuFi1GWQVzKJ4eebNIhvz15ib7iuM7BgobfQyztP1tSf8fCPSuZlpMhGMS35r8oOG5AMMfu6NowAPo3KH_ZKgKOYUzGIJlArDVJeFNW59g2LOJZNXR95BUSwqRopMXnet4qkFhaZ-HQvv7Pv3xX2EoPDA8KbpwfDm1m2mMq9vCeJ7TDT_eU3wR8j_IUCguNqUIW2I_t0OXj4IjT5T3AAqB8bdjTOJwHq_HHfSfyk3woOCuRvS8NukCWYVE-V-NcOgZUVVj3dRyqYuay3EgCdSqjxVd1nWjbi3Q095pJXTYO1j9mEsUBzFkRdhwOxy0J3UrWzVgTpxqsoWsWzbw9QNtWw0tdiXdXmqtDg1nDRHjr0oOXI6mA45VrwRQpTYiPbY9PehJqWrgetangQrOc3K2GN2PvowHkyMK3WiklzgwaqebNweEcS8Jf_P5Hmn-4TLEPMLE7q8XvTrGFnJrYkpfoomk-z2Fn3By6rrd970nNcvrA9rsN2U0hJzALwxvI0mTWt_HPzM8LZF23-KJfhfNCSGt-0qkeHteZtHh_8FAAD__y41k-Y">