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

    <tr>
        <th>Summary</th>
        <td>
            [InstCombine] Miscompilation where a select-shuffle fold keeps no-signed-zeros on the identity lanes it adds
        </td>
    </tr>

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

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

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

<pre>
    **Fuzzer Generated Test**
**Reproducer**
https://alive2.llvm.org/ce/z/sXAu8w

**Test Commit**
[e633c7da8ff144a11b3d875956fbaea06b969070](https://github.com/llvm/llvm-project/commit/e633c7da8ff144a11b3d875956fbaea06b969070)

**Description**
`foldSelectShuffleWith1Binop` keeps `nsz` on the identity lane it adds to the `fmul`: for `%v = +0.0`, that lane may return -0.0 where the source returns `%v` (the fold drops `ninf` for this reason in #201315).

**Steps to reproduce**
- Minimized test case (src), `input.ll`

```llvm
define <2 x half> @f(<2 x half> nofpclass(nan) %v) {
  %b = fmul nsz <2 x half> %v, <half 2.0, half 3.0>
  %s = shufflevector <2 x half> %b, <2 x half> %v, <2 x i32> <i32 0, i32 3>
  ret <2 x half> %s
}
```

- InstCombine output (tgt), `output.ll`

```llvm
define <2 x half> @f(<2 x half> nofpclass(nan) %v) {
  %s = fmul nnan nsz <2 x half> %v, <half 2.000000e+00, half 1.000000e+00>
  ret <2 x half> %s
}
```

**Output**

```
define <2 x half> @f(<2 x half> nofpclass(3) %v) {
#0:
  %b = fmul nsz <2 x half> nofpclass(3) %v, { 0x4000, 0x4200 }
  %s = shufflevector <2 x half> %b, <2 x half> nofpclass(3) %v, 0, 3
  ret <2 x half> %s
}
=>
define <2 x half> @f(<2 x half> nofpclass(3) %v) {
#0:
  %s = fmul nnan nsz <2 x half> nofpclass(3) %v, { 0x4000, 0x3c00 }
  ret <2 x half> %s
}
Transformation doesn't verify!

ERROR: Value mismatch

Example:
<2 x half> nofpclass(3) %v = < poison, #x0000 (+0.0) >

Source:
<2 x half> %b = < poison, #x8000 (-0.0) >
<2 x half> %s = < poison, #x0000 (+0.0) >

Target:
<2 x half> %s = < poison, #x8000 (-0.0) >
Source value: < poison, #x0000 (+0.0) >
Target value: < poison, #x8000 (-0.0) >

Summary:
  0 correct transformations
 1 incorrect transformations
  0 failed-to-prove transformations
  0 Alive2 errors
```

**CC**: @regehr
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy8VkFv4zYT_TX0ZWCDGtqyffDBkdcfvsNigSRoe6WkkcVWIgWSchL_-oKUnDhNvPVu0QYBLM1Qb2Yeh8MnnVMHTbRhizu22E1k72tjN04qK1tM02SSm_Jlw3DLcLvvTyey8D_SZKWnEh7J-cHF-HZ4uKfOmrIvyL46au87x8SW4Z7hXjbqSDhrmmM7M_bAcF8Qw_2J4d79tu1XTwHqjBYCQGbaVl3EWdxRKkSxLOWqqpL5XCZJLsrVcrFepFUuSfI0X6drvuRssWO4eh__oHzd57PCtAz3IYvxZ9pZ8zsVPiQ0BtzfHAfXl1nvyBVWdV4Z_ZZ1yivTlA_UUOEf6r6qGvpV-Tq5U9p0LOXwB1HngKVcu1N4Nxp8TaBK0l75F2ikJlAeZFk68CY6A2rbNyzlTGyhMjZYGC6OwMQOGN7xGY-WDHwt_YDRyhew5HurYcpnHJ5qshThnOltQaPTnbFCMgxXYUEoAUprxkSVroIzxPW1cmBJOqNBaWAokCciWTBczy65efChSm_AnhvllaIpfFVatepEJfiw8YV0FCI7WwSGMQtBle56P2tizXxkdviPm8m3JVVKEzCRITxDLZuKiS_A5rxiuPqLVZuqKxrpHMOVlprhGmLF4Xd5x_gWwnse2QxEg3anD8jxgyyYgwlwFvmOz2LGmfhyxnERxw2bf6TCh_36AJaPYFdiBLMSGK0iUwIhhgsP4hzLkv8EwQWylrtLygYGp_B_7Xxm2jwQZ3rf9T7u-MG_8T6Y_1vi3QXx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