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

    <tr>
        <th>Summary</th>
        <td>
            powi(x, n) is constant folded as if it were pow(x, (double)n)
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            floating-point,
            constant-folding
      </td>
    </tr>

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

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

<pre>
    The LLVM constant folder evaluates llvm.powi.f64(double fC, i32 iC) as if it were pow(double fC, double fC2). This leads to a deviation from the value that would be returned if the expression were not constant folded.

I reproduced it here using C: https://godbolt.org/z/vT4YMYKne

For C maybe you can argue that this doesn't matter because the definition of __builtin_powi says that it makes no guarantees about precision (though I think users expect at least consistency). However, we can't assume that the intrinsic came from the C builtin, so I think this is a problem.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxsk8-OozgQxp_GXEpBxCQQDhx600I72plba6U5tQwuwNvGRq5yMtmnX5nuTq-iuYAQ9dVXv_qjiMzkEFtx_EMcnzMVefahVU7f3tTN-pD1Xt_alxnh-_e_f8DgHbFyDKO3GgPgRdmoGAmsvSz56q8mH6uDkCftY28RxrOQZzClBHMWsgFFYEYwDFcMCKu_PobeP6SQTQ4vsyGwqDQBe1Cg8WIUG-9gDH4BnhFSCQg8K4arj1ZDjxCQY3Cok1mKwV9rQKKk24yd5wcWnYviWRRP789vEHANXsch5WCYkyiScROcRfkEM_NKonwSshOym7zuveXch0nI7l8hu8vL4eePn385_H_Szgc4w6JuPcLNRxiUAxWmz-I5oWqP5ISsGRbFjAF6HFQk3Cg0jsaZjd6P8PraR2PZuNfUdiB1o_dEJonfkMB5mKIKyjEigep9ZFgDDmZrhJAnnn2cZviWvN0bRMJAqVc4MChOfaf3PhlidMNtG8mf_ooXDGlYV0wQW7mKKC53EgTjOBhHZoBBLfg1rTN8VJ305O_eG70hULAG31tc8ky3pW7KRmXY7qumLMv6WMlsbptx7GtZVPvhOB4OfdnsGzUe6lrrppFKVZlpZSHL4iSbfVPKssrrsq5HPTaFrlDX1V4cClyUsfm2tT5MmSGK2FbH4nTKrOrR0nYSUo7WKzZu2q3eOBZSCnkWUn4uzy4tj3FT-nF8zkKbMu76OJE4FNYQ05cHG7bYpmEJefqV-F06CUOPq_jbK9kE92sRskniLAbbPiyj4Tn2-eAXIbvk_fHarcH_gwML2W2wJGS38f4XAAD__zizWGE">