https://bugs.llvm.org/show_bug.cgi?id=52563

            Bug ID: 52563
           Summary: Clang mishandles fast-math flags when pragmas are used
           Product: clang
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangb...@nondot.org
          Reporter: andrew.kay...@intel.com
                CC: htmldevelo...@gmail.com, llvm-bugs@lists.llvm.org,
                    neeil...@live.com, richard-l...@metafoo.co.uk

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"

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to