<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Mon, Nov 30, 2015 at 7:24 PM Gao, Yunzhong <<a href="mailto:yunzhong_gao@playstation.sony.com">yunzhong_gao@playstation.sony.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">According to <a href="http://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi.html" rel="noreferrer" target="_blank">http://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi.html</a>,<br>
"The high-order double-precision value (the one that comes first in storage) must have the larger magnitude."<br>
<br>
So the order of the two doubles in your fp128 is not affected by the endianness; although each individual double is.<br></blockquote><div><br></div><div>Of this part it's pretty clear, so I guess my questions are, more specifically:</div><div>1) Why </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hope that helps,<br>
- Gao<br>
<br>
<br>
________________________________________<br>
From: llvm-dev [<a href="mailto:llvm-dev-bounces@lists.llvm.org" target="_blank">llvm-dev-bounces@lists.llvm.org</a>] on behalf of Tim Shen via llvm-dev [<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>]<br>
Sent: Monday, November 30, 2015 7:17 PM<br>
To: <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
Subject: [llvm-dev] Endianness for multi-word types<br>
<br>
Hi,<br>
<br>
I'm recently trying to investigate ppc_fp128 related problem. Here is a minimal C++ test case that seems wrongly compiled:<br>
<br>
long double id(long double a) {<br>
  return a;<br>
}<br>
bool f(long double x) {<br>
  return id(__builtin_fabsl(x)) >= 0;<br>
}<br>
int main() {<br>
  if (f(-123.l)) {<br>
    return 0;<br>
  }<br>
  return 1;<br>
}<br>
<br>
The program compiled with command:<br>
clang++ -static -target powerpc64le-linux-gnu bad.cc<br>
Returns 1 on a ppc machine.<br>
<br>
I did some investigation, it turns out in lib/CodeGen/SelectionDAG/DAGCombiner.cpp, a combination is wrongly assuming the endianness for the i128 bitcasted from a ppc_fp128 (two doubles bit-concatenated together):<br>
  // fold (bitconvert (fabs x)) -> (and (bitconvert x), (not signbit))<br>
<br>
This reveals that endianness conversion concerning ppc_fp128 or i128, and big-endian or little-endian target is too confusing to me.<br>
<br>
I can certainly fix this case by using a "smarter signbit" (e.g. 0x00000000000000001000000000000000), but this seems more confusing. I wonder if anyone has the best background knowledge here?<br>
<br>
Background I found: <a href="http://llvm.org/klaus/llvm/commit/1ef2cec146099f4bf46c31b913c7f1538935a867/" rel="noreferrer" target="_blank">http://llvm.org/klaus/llvm/commit/1ef2cec146099f4bf46c31b913c7f1538935a867/</a><br>
<br>
Thanks!<br>
</blockquote></div></div>