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

    <tr>
        <th>Summary</th>
        <td>
            [InstCombine] Wrong negation of vector subtraction
        </td>
    </tr>

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

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

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

<pre>
    https://github.com/llvm/llvm-project/blob/9a7519fdb39f21a807189e1ed06826b43db929e1/llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp#L231-L239

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

```llvm
----------------------------------------
define <4 x i16> @vec_const_sub_const_sub.2(<4 x i16> %arg) {
#0:
  %t0 = sub nuw <4 x i16> { 8, 8, 8, 8 }, %arg
  %#1 = mul <4 x i16> %t0, { 0, undef, undef, 3 }
  %t1 = sub nsw nuw <4 x i16> { 2, 2, 2, 2 }, %#1
  ret <4 x i16> %t1
}
=>
define <4 x i16> @vec_const_sub_const_sub.2(<4 x i16> %arg) {
#0:
  %#1 = mul <4 x i16> %arg, { 0, undef, undef, 3 }
  %t1 = add <4 x i16> %#1, { 2, 2, 2, 65514 }
  ret <4 x i16> %t1
}
Transformation doesn't verify!

ERROR: Target's return value is more undefined

Example:
<4 x i16> %arg = < poison, #x0008 (8), #x0000 (0), poison >

Source:
<4 x i16> %t0 = < poison, #x0000 (0), #x0008 (8), poison >
<4 x i16> %#1 = < poison, #x0000 (0), #x0000 (0)       [based on undef value], poison >
<4 x i16> %t1 = < poison, #x0002 (2), #x0002 (2), poison >

Target:
<4 x i16> %#1 = < poison, #x0000 (0), #x0000 (0), poison >
<4 x i16> %t1 = < poison, #x0002 (2), #x0002 (2), poison >
Source value: < poison, #x0002 (2), #x0002 (2), poison >
Target value: < poison, #x0002 (2), #x0002 (2), poison >

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/eJy8Vk1v4zYQ_TXjCxGDHEqWdNDBH2ugxaIF0gWKnhaUSDkMZNIgKSfpry8oKbbsddJsu9ggoKkR5703T6I4wnu9M0qVkK4g3cxEFx6sKytrdo-deZxVVr6UDyEcPPAl4BZwu9Phoavmtd0Dbtv2-Ppzd3D2UdUBcFu1tgLcFiJLWdHIihcNMpHTjOWFYkrSRY6LKuGyKrBQbIKjY94XJ4xvrNt7wO0vxoe13VfaqMur39ROBOvm9eEAyD8jZ3efkRdAN0CXw7hs9VEhcepgXQC-JJeViP72PHLPrdsBbuvI8TfgVnXu17_WUyxY0OG_l9qH7j74N6yWqtFGEeDrhDwTzRbAPxFI6FHVX2trfPjqu-o8myNgfrUYUxFlFgSy1agKOY319BckrgiUAN8Q31XEdE_XdNmK5IDr6UAg28TJiH5GAuSsx9p37TVO5OmTshXpJ52RqrmY8B54IoydhfmnN8RhzJwME3FRziucU-GGovH2iRb4Bvinn-r--571-f_FNCHlt2i9ISPclW-LNGXJFOpjhp02ngjaGiKt8gYwC-SonG5eANl0R3y6v__9Pu6qL8LtVADMfOTpnCFH0XaKaE_21qmhOm2UvMh-FvtDq0723TKrrx34mhys9tYMLwJ_ppTmBDDPAYtJjMYYHWNDBjk9_2H8w3aufodz3Dw3KS_gb8n4hvLWA_s-_HOMFpCuKuGVJNYMjg4uQ7r5EHl4hxojDV5SX8Ruuzk-9zfd_D_1_vSShldj9JQvfxDqYNGPRh0Vd_u9cC-TDxAltXVO1YGEi53sXxcwos2_LKGkEbpV8i7YeKIf1dsLx-NVOWedvzolZ7LksuCFmKmSZZziIskwmz2UWDdZI5tUcmQ8Zc2C5kJmNE94xnmW8ZkukWLCKKc0pSku5lXR8ByZ4s1CZbKSkFC1F7o9Hdwz7X2nSsYSlvNZKyrV-r6hQTTqifR3ATH2N67sW5Wq23lIaKt98GeYoEPbd0LTniPdkD-dNTtiYr8RP4u2IUdVB-viWRacqGN01rn2-xulXlrsckbtxxL_CQAA___UoZDd">