[LLVMdev] ConstantFoldBinaryFP and cross compilation

Sergei Larin slarin at codeaurora.org
Fri Apr 26 12:44:19 PDT 2013


Dan, and anyone else interested. 

 

  I am not sure if this has been discussed before, but I do have a case when
the following logic fails to work:

 

lib/Analysis/ConstantFolding.cpp

 

static Constant *ConstantFoldBinaryFP(double (*NativeFP)(double, double),

                                      double V, double W, Type *Ty) {

  sys::llvm_fenv_clearexcept();

  V = NativeFP(V, W);

  if (sys::llvm_fenv_testexcept()) {

    sys::llvm_fenv_clearexcept();

    return 0;

  }

 

..

 

This fragment seems to assumes that host and target behave in exact the same
way in regard to FP exception handling. In some way I understand it, but. On
some cross compilation platforms this might not be always true. In case of
Hexagon for example our FP math handling is apparently more precise then
"stock" one on x86 host.  Specific (but not the best) example would be
computing sqrtf(1.000001). Result is 1 + FE_INEXACT set. My current linux
x86 host fails the inexact part. resulting in wrong code emitted.

 

  Once again, my question is not about this specific example, but rather
about the assumption of identical behavior of completely different systems.
What if my target's "objective" is to exceed IEEE precision? .and I happen
to have a set of tests to verify that I do J

 

Thank you for any comment.

 

Sergei

 

 

---

Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by
The Linux Foundation

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130426/acd2cd4c/attachment.html>


More information about the llvm-dev mailing list