[LLVMdev] FP Intrinsics

Andrew Lenharth alenhar2 at uiuc.edu
Thu Mar 17 07:18:17 PST 2005

On Wed, 2005-03-16 at 10:38, Chris Lattner wrote:
> On Fri, 11 Mar 2005, Morten Ofstad wrote:
> > I am trying to make the FP intrinsics (abs, sin, cos, sqrt) I've added work 
> > with the X86ISelPattern, but I'm having some difficulties understanding what 
> > needs to be done.

I have some notes for Alpha below, if you are so inclined :)

> 1. I don't think we need an "llvm.abs" intrinsic at the llvm level.  This
>     can be modeled as a pair of setcc/select instructions.

I agree.

> 2. My objection to llvm.abs does not apply to the FP_ABS
>     node you added: it is fine.  Additionally, the target-independent
>     selection dag machinery should be the one that notices the relevant
>     setcc/select pairs at the llvm level to fabricate the FP_ABS node.

A FP_ABS node is nice, alpha has abs (cyps F31, src, dst)

> 3. On X86 at least, sin and cos are not defined over the full numeric
>     range.  These instructions are useful for applications like yours, and
>     situations where a flag like "-ffast-math" has been provided.  Because
>     of this, please name the intrinsics and nodes sin_approx and
>     cos_approx.  I don't think that sqrt on the X86 has this limitation,
>     so its intrinsic can be named just "llvm.sqrt".

I think it is the same with alpha's sqrt.  Though sin and cos will have
to be lowered.

> > The part I don't quite understand is what to do for targets that don't have 
> > these instructions (although I'm only interested in X86 myself, I would like 
> > to see these patches in the official LLVM version as it's some work to 
> > maintain them)

So alpha has sqrt and abs, but not sin and cos.  Once you have the
SelectionDag making the nodes for the intrinsics, let me know.


More information about the llvm-dev mailing list