[llvm-bugs] [Bug 45211] New: Wrong optimization with ppc_fp128: 1 - 1 -> -0
via llvm-bugs
llvm-bugs at lists.llvm.org
Sun Mar 15 10:23:04 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=45211
Bug ID: 45211
Summary: Wrong optimization with ppc_fp128: 1 - 1 -> -0
Product: new-bugs
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: new bugs
Assignee: unassignedbugs at nondot.org
Reporter: ch3root at openwall.com
CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org
For a PowerPC target, with the type long double (IBM extended double /
double-double / ppc_fp128) expression `1 - 1` is folded to `-0` instead of
`+0`. This type is not IEEE 754 type but for values representable in double the
results should be the same, I guess?
----------------------------------------------------------------------
#include <stdio.h>
int main()
{
long double x = 1;
printf("%Lg\n", x - 1);
}
----------------------------------------------------------------------
$ clang -target ppc64-linux-gnu -std=c11 -Weverything test.c && qemu-ppc64
/usr/powerpc-linux-gnu/lib64/ld64.so.1 --library-path
/usr/powerpc-linux-gnu/lib64 ./a.out
0
$ clang -target ppc64-linux-gnu -std=c11 -Weverything -O3 test.c && qemu-ppc64
/usr/powerpc-linux-gnu/lib64/ld64.so.1 --library-path
/usr/powerpc-linux-gnu/lib64 ./a.out
-0
----------------------------------------------------------------------
clang x86-64 version: clang version 11.0.0
(https://github.com/llvm/llvm-project 429d792f23f2e72628cae763667bca60d69853e7)
----------------------------------------------------------------------
--
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/20200315/767dc996/attachment.html>
More information about the llvm-bugs
mailing list