<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Clang mishandles fast-math flags when pragmas are used"
   href="https://bugs.llvm.org/show_bug.cgi?id=52563">52563</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang mishandles fast-math flags when pragmas are used
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>andrew.kaylor@intel.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When pragmas are used that modify the fast-math flags, clang doesn't correctly
apply the changes to all instructions. I've seen this with phi and fneg
instructions. There may be others.

Here are some examples (compiled with -funsafe-math-optimizations, which
applies 'reassoc nsz arcp' outside pragma scopes):

```
#pragma clang fp reassociate(off)
double foo(bool flag, double x, double y) {
  return flag ? x : y;
}
```

clang generates a phi instruction with the 'reassoc' flag set.

```
#pragma clang fp reassociate(off)
double bar(double x) {
  return foo(x < 0, -x, x);
}
```

Here clang correctly omits the 'reassoc' flag from the fcmp but incorrectly
sets it for the fneg.

```
#pragma clang fp reassociate(off)
void fubar(double x, double *pneg, double *psub) {
  *pneg = -x;
  *psub = 0.0-x;
}
```

Here clang correctly omits the 'reassoc' flag from the fsub but incorrectly
sets it for the fneg.

The same problem occurs with "pragma float_control"</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>