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

    <tr>
        <th>Summary</th>
        <td>
            Invalid fabs/fptrunc transformation in InstCombine:  target is more poisonous than source.
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            miscompilation,
            llvm:instcombine
      </td>
    </tr>

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

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

<pre>
    `InstCombine` transforms the following input `@src` into `@tgt`. According to Alive2, the target is more poisonous than source.

Source is `@test_shrink_intrin_fabs_fast_double_src` in `llvm/test/Transforms/InstCombine/double-float-shrink-2.ll`

```
declare double @llvm.fabs.f64(double)
declare float @llvm.fabs.f32(float)


define float @src(double %D) {
  %E = call fast double @llvm.fabs.f64(double %D)
  %F = fptrunc double %E to float
  ret float %F
}

define float @tgt(double %D) {
  %1 = fptrunc double %D to float
  %F = call fast float @llvm.fabs.f32(float %1)
  ret float %F
}
```


Alive2:
```
ERROR: Target is more poisonous than source

Example:
double %D = #x58f0015ef8006530 (2583114182655651338247823035071900255382535331591702140808965737448017332694647792277492805944677030350613680369967300608)

Source:
double %E = NaN
float %F = NaN

Target:
float %1 = #x7f800000 (+oo)
float %F = poison
Source value: NaN
Target value: poison
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyNVEtv2zgQ_jXShYjBN6mDDkmdAL10gWzvASVRNre0aIhU2v33O5RsWUm7aQ2BNOf5fcPhNKH7ty4k_jzE9CmcGjdYOKE0miH2YTxFlI4W9cH78N0NB-SG85QQmBQcx7HNtm5I4SJJhwR_dui-bcPYZXtQ3Xv3amlBP82hkhkPNiEX0SmMFp2Di2EIU85jBhTDNLZ2V-B9ge-X9e9ZlB0uOWxML_E4uuHbC6SG_aU3TYQF5F2YGm9fVmTZx_vXU0Gfsh9sX1dmcNiypk-L813vg0l3S4Y7uvM-590Aysflm4-dbb0BJos3AoQ54S5j2vWSF1QvmoJWbx3mPO_sGdRJz4rVfLt2tgeoN8_M8xofFVTswQsV6mGxRln0iAq2R63xHuUK_RbmNcwmxNMcoj-ncRpadDN7zLe7gL0Yj3CzF3DgdkGu9h9RyC3zGwrkf_Lvf8q_gr3x_bjKc_gN248JvL347XrpcfbrFnl8fv7rGZTo6x80_zbs4w9zOkPrXONuuWeaBWU_hO4xJsL2GmMpGAahpkIzQjjRVAohBWFMU640ZZgJrEiFMRUCZIIJxoioiMKUcKyxrqRQTHGuMVGMUVlxyZWqKFWKV1RjUXEulcJzJEmY1JjJqpKKQXas33Xt8nZ_AX_pyi_my6K4lfytfFmXqq1Rbhe31kBl8vDL3Av6EMKK413kpeJvBsur8VOGeMt6uaVVsXVab7a0NZFSVFRppcuuZl3FKlMml7ytPw_g7DqU2w0Gy7V116lqkgtDHk_bAQSZ_mw6ltPo62NK55hrQp_gO7h0nJpdG_Kkuwy8vN2dx_CPbfPgczFONqOB3qhweawlJi3tVdMa1jWCko7JlsvKtJVoOyF46U1jfawL8VBQenIRop-dn7GDIA902OZk7N4BkfY6SWkh9qWrKaaUYAJdwjnTO0MVb43pCDWCmErAm7Qn4_xufplhPJRjPWNupkPMD9bFFG9KE6M7DNbOeCC-mdIxjHV_NMehnMnVM7P_AIG0_qU">