<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Wrong optimization with ppc_fp128: 1 - 1 -> -0"
   href="https://bugs.llvm.org/show_bug.cgi?id=45211">45211</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Wrong optimization with ppc_fp128: 1 - 1 -> -0
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>ch3root@openwall.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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
(<a href="https://github.com/llvm/llvm-project">https://github.com/llvm/llvm-project</a> 429d792f23f2e72628cae763667bca60d69853e7)
----------------------------------------------------------------------</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>