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

    <tr>
        <th>Summary</th>
        <td>
            FP optimization wrong wrt NaNs?
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

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

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

<pre>
    here's a function:
```llvm
define float @f(float %0) {
  %2 = fpext float %0 to double
  %3 = fptrunc double %2 to float
  ret float %3
}
```
InstCombine elides the ext/trunc and just returns %0. Alive finds that this optimization changes the behavior-- the original code quiets an incoming SNaN, whereas the optimized code obviously doesn't do that (sorry, no CE link, this example times out there)
```
Example:
float %#0 = #x7f808003 (SNaN)

Source:
double %#2 = #x7ff8000000000000 (QNaN)
float %#3 = #x7fc00000 (QNaN)

Target:
Source value: #x7fc00000 (QNaN)
Target value: #x7f808003 (SNaN)
```
our understanding is that this behavior is a violation of what LLVM is currently trying to do. is Alive right here, or LLVM? thanks
cc @RalfJung @nunoplopes 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VNuO2zYQ_RrqZbAGTVm3Bz1sdiOgRbpom6LvlDiSmFCky4sv_fqCor1WgjSGIZvkmTNHc2bInZOTRmxJ8YEUrxkPfja2tTjhbLPeiGs7o0XCKgccxqAHL40m-TOhr4Q-k5Kmr1KnJW0JHKVGGJXhHsiBjoTVtwUrKGENkOpDgkLcYkDyVxiPePHwwIE3IEzoFW6g-Q3qbdDD7ThReJNi72CLG7L8prV6_U50Wv6inX8xSx9Vo5ICHfgZAS-esC6l4lrAl-B85A1Wu1XiDp6VPCGMUosYwj34WTowRy8X-S-PhYJh5nq6MfY485M09ulpXRorJ6m5gsEIhH-CRO-Aa5B6MIvUE3x-42-EvcA5OsATx40cRYoy_Uma4NQVhEGnCas8CJPEEFY7Y-01UmgDLx9BSf01rlaZeOHLUSF4uaADE6L61enmh1X6mODvzr9Xl7Ccrr4Qll-qsaY1pXlMnuTf2dbnZxPs8OB4OEhYzjYkY003n0j2x5ZsmzvfhA0_hqfnX9xO6N9zJylw4ipEQT9nSLHfg__vVb8tnAkWghZonedaRF_ltlvuTRF3OZykUalxzAjnCPr06e_f4tkQrEXt1RW8vUaWdUB28Si1oZXT7CFZ-ALGrpEk72Iu_dUlMcMQR_JPrsZfg57ifx20OSpzRAeZaHPR5A3PsN1XjO6boqmLbG4bsWcUaVOOyCiW9QErhlhWtdjzcl8PmWwZZQda0WJf7nNa7PhYlFV1qGhZ9g2WSA4UFy7VLt4TO2OnTDoXsG2qOq8yxXtU7n4F2TaCnvowOXKgSjrvHmFeeoVt9_u3U3a2Rk9wth7e-JsjeZcFq9rZ-6OLhrOOsG6Sfg79bjALYd16XaWfp6M1X3CIw75qcoR1SdapZf8FAAD__z6yjWo">