[llvm-bugs] [Bug 52563] New: Clang mishandles fast-math flags when pragmas are used
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Nov 19 12:57:53 PST 2021
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: unassignedclangbugs at nondot.org
Reporter: andrew.kaylor at intel.com
CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
neeilans at live.com, richard-llvm at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20211119/b04fcf0c/attachment.html>
More information about the llvm-bugs
mailing list