[llvm-bugs] [Bug 49132] New: double-double constant expression evaluation can produce spurious NaN
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Feb 10 14:46:01 PST 2021
https://bugs.llvm.org/show_bug.cgi?id=49132
Bug ID: 49132
Summary: double-double constant expression evaluation can
produce spurious NaN
Product: clang
Version: trunk
Hardware: Other
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: bbaren at google.com
CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
neeilans at live.com, richard-llvm at metafoo.co.uk
Created attachment 24512
--> https://bugs.llvm.org/attachment.cgi?id=24512&action=edit
minimal example
When compiling for POWER (-target powerpc64le-linux-gnu), Clang can incorrectly
simplify long double (double-double) expressions to NaN:
$ uname -m
ppc64le
$ cat ldbl.c
extern int printf(const char* restrict, ...);
int main() {
long double a = -0x1.1e282e024debdb875f47f6c85p+1021L;
printf("%Le\n", a + 0x1.fffffffffffff7ffffffffffff8p+1023L);
}
$ clang -Wall -Wextra -O1 -o ldbl ldbl.c
$ ./ldbl
nan
Inspecting the generated bitcode shows that Clang has statically evaluated the
double-double addition to a NaN, but by IEEE 754, adding two non-NaN inputs
should never produce a NaN output.
GCC produces the correct answer for this computation, though only when
optimizations are enabled (see
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99048).
--
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/20210210/0888e233/attachment.html>
More information about the llvm-bugs
mailing list