<div dir="ltr">Hi,<div><br></div><div>I'm recently trying to investigate ppc_fp128 related problem. Here is a minimal C++ test case that seems wrongly compiled:</div><div><br></div><div><div>long double id(long double a) {</div><div>  return a;</div><div>}</div><div>bool f(long double x) {</div><div>  return id(__builtin_fabsl(x)) >= 0;</div><div>}</div><div>int main() {</div><div>  if (f(-123.l)) {</div><div>    return 0;</div><div>  }</div><div>  return 1;</div><div>}</div></div><div><br></div><div>The program compiled with command:</div><div>clang++ -static -target powerpc64le-linux-gnu bad.cc<br></div><div>Returns 1 on a ppc machine.</div><div><br></div><div>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):</div><div>  // fold (bitconvert (fabs x)) -> (and (bitconvert x), (not signbit))<br></div><div><br></div><div>This reveals that endianness conversion concerning ppc_fp128 or i128, and big-endian or little-endian target is too confusing to me.</div><div><br></div><div>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?</div><div><br></div><div>Background I found: <a href="http://llvm.org/klaus/llvm/commit/1ef2cec146099f4bf46c31b913c7f1538935a867/">http://llvm.org/klaus/llvm/commit/1ef2cec146099f4bf46c31b913c7f1538935a867/</a></div><div><br></div><div>Thanks!</div></div>