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

    <tr>
        <th>Summary</th>
        <td>
            Wrong select folding for undef conditions by InstCombine
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    https://github.com/llvm/llvm-project/blob/7eae9bb856135136cddc4208a2b1546e9db44c9c/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp#L3582-L3585

Alive2 report: https://alive2.llvm.org/ce/z/Qtu72J


```ll
----------------------------------------
define <2 x i1> @fun0(<2 x i1> %val0, <2 x i1> %val1) {
#0:
  %val2 = select <2 x i1> %val0, <2 x i1> %val0, <2 x i1> %val0
  %val3 = select <2 x i1> { undef, 1 }, <2 x i1> { 1, 1 }, <2 x i1> %val2
  ret <2 x i1> %val3
}
=>
define <2 x i1> @fun0(<2 x i1> %val0, <2 x i1> %val1) {
#0:
  ret <2 x i1> { poison, 1 }
}
Transformation doesn't verify!

ERROR: Target is more poisonous than source

Example:
<2 x i1> %val0 = < #x0 (0), #x0 (0) >
<2 x i1> %val1 = < #x0 (0), #x0 (0) >

Source:
<2 x i1> %val2 = < #x0 (0), #x0 (0) >
<2 x i1> %val3 = < #x0 (0)     [based on undef value], #x1 (1) >

Target:
Source value: < #x0 (0), #x1 (1) >
Target value: < poison, #x1 (1) >

Summary:
  0 correct transformations
  1 incorrect transformations
  0 failed-to-prove transformations
  0 Alive2 errors
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8VV2P6jYQ_TXDi7XIGefzIQ-wXKRWlaruXqnPdjIBXxkb2Q7d7a-v8gELvbDtlaoiZMh4fObM-GRGhqB3lqiGbA3ZZiH7uHe-Vs5-6y0tlGvf632MxwBiBbgF3O503Pdq2bgD4NaY0_nn6ejdN2oi4FYZpwC3BUmqlCqzPBFZIvKmbZsUeSlRJVmaU9WqNG2q5gpHD-e-emlD5_whAG5_siE-u4PSlm6fXslQE5fN8QgofhFZiU_DmgHfAF9N68roEyHzdHQ-glix21TkuL0cgi-d3wFumyHIn4Db32Jf4M_XWPOa8-lrzGR4-pefybulTltiIJ6RvTGdgPjCIOVdbzlgeWvG7CQNB3xmd-wJYMWgWM-sUPAhq_GBzS7IQGxYGMt0D-IR9GP7Dbx4DF-sWW9b6gaghEGx-R6xWLPkk-0pgXNAT3cTEHPyxWb-IzYgvvyfhf6eWLFmR6eDsx_J3ZK8iFtG7SxrHQULWER2Iq-7d8DkWm5fXl5-fRmE-1X6HUWmAzs4T3MM1wcW99Ky4Hrf0M3BN3k4GrpwvZfxeIEgnhmgeOMMsOSA1ViHawO7FPVeeX4cZFxfJ8af0MP_gp54AMIryNZKBmqZs5NY2UmaniDbnCMkg3dyh_t0FxfuUyrzcbF6TPkO4HytN2c_9PMpi9f-cJD-_UqNnDXO--F1jDciC2eHhGn7Dy6cdVIbap-iGxr6iR47zs2VvHc-_K07LtpatJWo5ILqpECeF0VVZot9nck2T3OF2KVpmTWdrKjqqqYsG4VJIrOFrpFjyosk4TnPMVuS6lRTZmVVlmVX8hxSTgepzaVtL3QIPdVVmYpsYaQiE8ZphmjpDzZuAuIw3Hw9DirV7wKk3OgQwwdK1NFQ_bt3dnfuap0zrbY71jk_a6RxttVjHZh6Z1fTaNF78-ODciQ3TLmJ_KnGvwIAAP__j-cPeg">