[PATCH] R600/SI: implement range reduction for sin/cos
Matt Arsenault
arsenm2 at gmail.com
Fri Jun 20 12:15:30 PDT 2014
On Jun 20, 2014, at 11:50 AM, Grigori Goronzy <greg at chown.ath.cx> wrote:
> On 20.06.2014 20:02, Matt Arsenault wrote:
>> I think it would be better to to this with custom lowering rather than
>> the instruction patterns.
>
> Probably, this is just my first naive attempt to make a useful
> contribution. I hardly know the R600 backend and/or LLVM. I guess we
> should also try to skip the range reduction if it can be determined that
> inputs are restricted to the allowed range.
>
> Can you give me any pointers? And how should this be tested?
>
Look at R600TargetLowering::LowerTrig. You want to do basically the same thing except with the scale and range on SI. Somewhere in SITargetLowering you need setOperationAction(ISD::FSIN MVT::f32, Custom), and have LowerOperation call the new function.
There should be a lit test like the others in test/CodeGen/R600, an ll file with a few small examples that have their output checked
You might want to add an sample something like sin(2.0 * x). With your current version, this will expand to sin( fract((1.0/ 2pi) * 2.0 * x)). With the custom lowering this the 2 multiplies by constants should be able to simplify into one multiply by 1.0/pi
- Matt
More information about the llvm-commits
mailing list