<div dir="ltr"><div>Hello,</div><div><br></div><div>I'm making a compiler utilizing LLVM. </div><div>Because I want the compiler to support 128bit floating-point operations, I added the code for 128bit floating-point operations and tested these operations in i686, x86_64, SPARCv8 and SPARCv9 machines.</div><div>Generated codes by LLVM operated normally when using x86_64, SPARCv8 and SPARCv9 machines, but generated codes in a x86 machine produce wrong result. </div><div><br></div><div>Because Clang supports __float128 type, I also tried to test using Clang 3.9 version.</div><div>However, I could not get the correct result of 128bit floating-point operations using Clang.</div><div><br></div><div>For example, C source code that included operations of 128bit floating-point is as follows:</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>#include <stdio.h></div><div>#include <quadmath.h></div><div><br></div><div>int main() {</div><div>    __float128 a = 3.14;</div><div>    char buf[128];</div><div><br></div><div>    quadmath_snprintf(buf, sizeof(buf), "%QE", -a);</div><div>    printf("%s\n", buf);</div><div>    quadmath_snprintf(buf, sizeof(buf), "%QE", a * 5.0);</div><div>    printf("%s\n", buf);</div><div>    quadmath_snprintf(buf, sizeof(buf), "%QE", a + 5.0);</div><div>    printf("%s\n", buf);</div><div><br></div><div>    return 0;</div><div>}</div></blockquote><div><br></div><div>After compilation, the correct result of the compiled program must be </div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>-3.140000E+00</div><div>1.570000E+01</div><div>8.140000E+00.</div></blockquote><div><br></div><div>However, I could not get the right result from the program that compiled by Clang 3.9.</div><div>(the result of the program that compiled by gcc 4.8.4 was correct)</div><div><br></div><div>I think that IR codes generated LLVM for 128bit floating-point operations are not wrong, but assembly generated from LLVM IR codes produced wrong result. </div><div>(: Because the compiled program produced the wrong result only in x86 machine)</div><div><br></div><div>How can I get the right result of 128bit floating-point operations using LLVM?</div><div><br></div><div><br></div><div>[ Environments ]</div><div>- CPU: Intel(R) core(TM) i7-6700</div><div>- OS: Ubuntu 14.04 (32bit)</div><div>- LLVM target triple: i686-pc-linux-gnu</div><div>- LLVM version: LLVM 3.8 / LLVM 3.9</div><div>- Clang version: 3.9</div><div>(※ use gcc 4.8.4 for building LLVM & Clang)</div><div><br></div><div><br></div><div>Thank you. :)</div><div><br></div><div>Sincerely, </div><div>Stella</div></div>