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: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]

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.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to