<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: two parts of ppc_fp128 are swapped"
href="https://bugs.llvm.org/show_bug.cgi?id=45137">45137</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Wrong optimization: two parts of ppc_fp128 are swapped
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Other
</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, when two parts of long double (IBM extended double /
double-double / ppc_fp128) are accessed directly and their values are visible
to the optimizer, they are swapped:
----------------------------------------------------------------------
#include <string.h>
#include <stdio.h>
__attribute__((optnone)) // imagine it in a separate TU
static void *opaque(void *p) { return p; }
int main()
{
long double d = 1;
unsigned long l[2];
memcpy(&l, &d, sizeof d);
printf("%016lx %016lx\n", l[0], l[1]);
opaque(&l); // hide it from the optimizer
printf("%016lx %016lx\n", l[0], l[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
3ff0000000000000 0000000000000000
3ff0000000000000 0000000000000000
$ 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
0000000000000000 3ff0000000000000
3ff0000000000000 0000000000000000
----------------------------------------------------------------------
clang x86-64 version: clang version 11.0.0
(<a href="https://github.com/llvm/llvm-project">https://github.com/llvm/llvm-project</a> feb20a159410dfec4055428911c7eb2bc908cf12)
----------------------------------------------------------------------
The output line "0000000000000000 3ff0000000000000" is wrong.</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>