[LLVMdev] Floating point instructions patch
morten at hue.no
Fri Apr 29 01:31:27 PDT 2005
Chris Lattner wrote:
> The patches I didn't apply are these:
> 1. Match (Y < 0) ? -Y : Y -> FABS in the SelectionDAGISel.cpp file. We
> already catch this at the DAG level. If we aren't, please let me know.
OK, no problem - I was just told last time I tried to get my patch in that this was needed because the C++ frontend
generated this code, I'm generating calls to fabsf() so for me this is unimportant ...
> 2. Codegen fsin/fcos to fsin/fcos for X86. We cannot do this, except
> under the control of something like -enable-unsafe-fp-math. These
> instructions are architected to have a limited range.
OK, I will add this flag.
> 3. Codegen fsqrt/fsqrtf C functions to the FSQRT dag node. These
> functions can set errno, so this is not a safe transformation. The
> proper way to do this is to introduce an llvm.sqrt.f32/llvm.sqrt.f64
> pair of intrinsics to represent these operations without errno. The
> optimizer can then turn fsqrt calls into these intrinsics when errno is
> provably never used or if a compiler option is specified to ignore
> errno. Also, your work could just generate llvm.sqrt.* calls
Actually, in my first patch these instructions (including fabs) were all intrinsics.
My code generator used to generate llvm.sqrt calls, so it's no problem to go back to that.
> 4. Codegen of fsin/fcos libm calls to FSIN/FCOS dag nodes. We really do
> need to be able to legalize these for targets that don't support them
> before we can do this. The easiest way to do this is to check the
> TargetLowering information for the operation to see if they are
> supported. If not, leave them as function calls in the
> SelectionDAGISel.cpp file. The alternative way is to have legalize
> lower them to libcalls. This is also needed for fsqrt, though sin/cos
> don't set errno.
The first solution is what I went for the first time around, but I was told that it should be lowered to libcalls. I was
unable to implement this as I don't see how I get the information about what type (float/double) the call originally
used. When the DAG is legalized these are all promoted to f64, right? If you just tell me how, I will fix this one also...
> I hope that committing the patches I did will significantly help your
Yes, thank you very much!
More information about the llvm-dev