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

    <tr>
        <th>Summary</th>
        <td>
            -ffp-contract difference for runtime / compile-time operations
        </td>
    </tr>

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

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

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

<pre>
    I have a piece of code that computes different floating point results depending on whether the computation happens at compilation time or at runtime (see [https://godbolt.org/z/q65q4f7c3](url) ).

When the values are known at compile time the compiler contracts the operation and computes the result. When they are not known, the expression is computed at runtime without contraction.

```
#include <iostream>
#include <cmath>
#include <iomanip>

int main() {
  double x = 30.508474576271183309;
  double y = 6.1016949152542370172;

  double r = (x-std::trunc(x/y)*y);

  std::cout << std::setprecision(17);
  std::cout << "compile time (w/ fma): " << r << std::endl;

  volatile double *xx = &x;
  volatile double *yy = &y;

  r = (*xx-std::trunc(*xx/(*yy))*(*yy));
  std::cout << "runtime (w/o fma): " << r << std::endl;

  r = std::fma(std::trunc(*xx/(*yy)),-(*yy),*xx);
 std::cout << "runtime (w/ explicit fma): " << r << std::endl;

  return 0;
}

```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJycVF2PozgQ_DWdFyuRaUMgDzywmUO6X3DPjmkG7xmbtU0-7tefIJBkZvZ0q5UioVSXu6sLXDIE_W6JSsi-Qfa2kWPsnC-_K-k9aS83J9fcyj9ZJ8_EJBs0KWKuZco1xGInI1OuH8ZIgTW6bcmTjaw1TkZt39ngtI3MUxhNDKyhgWwz4c6yS0exI89iR0sLGbWzrJPDQDawpbM2dzjqnpjzE-xHO_8DLAIRg-xbF-MQQFSANWD97pqTM3Hn_Dtg_Q9g_WOf_UjbXAnI3gCL0RvAAwM87IBXwKu_OrKzkLM0IwUmPbG_rbvYpwq6K1jVakOeKWejlyqGGXYD-btWaZunK1PpbsCOrXNu8wTr4n0K4HGm0XXwFMLUQoe1Q_O68kXHzo3xMVk7u6wAe778eAUotFVmbIiBOGoXoifZg_jjS031MnY_K2jXS6uHpcSr6TX2UlvAYrYu_wa8Yqxx48kQuzIQb0zwXcaLNE-zfI95khRC8AOID8zbzNzvEp7sD-khyTBLUeQ8yfHOfCX7mQxYXLchNtP7FVX0o1UTBFjfAA-A1fx4Hn5Q1eQUiCOI4xMMFAdPSk8uAxZJ_jj8HycB8cMXAFhcAGvW9nI-Wk2Mley_zCPbmBdxZzd9z4bWFQGr63VZc39dhfyEdbutrNtLu4dDc5-vLs3wfCuKucds2OTZJ-B_DHi5cdPu7jeXv6t9VOcmxS9rPm4_IMeFt4r_Re3TJTNa6fi7O1AcvWV8gfK3T9dv05SiOYiD3FCZ5ClPEdMk2XQlcTqJLG1UzlMUSihSXCV50opDgTI5bXSJHDM-8YuUJ8mu4YoKTESy50i53EPKqZfa7Iw591O6bXQII5UJFlmabYw8kQlzjiNaurC5CohTrPtyOrQ9je8BUm50iOHZJupoqNy27bBdg-UR5opY6_xL5tZr_m3vkbymXtiM3pSfkljHbjztlOsB62nc8tgO3n0nFQHrWWQArJctziX-GwAA__-V9_co">