[PATCH] R600/SI: implement range reduction for sin/cos
Tom Stellard
tom at stellard.net
Fri Jun 20 12:14:10 PDT 2014
On Fri, Jun 20, 2014 at 07:27:11PM +0200, Grigori Goronzy wrote:
> These instructions can only take a limited input range, and return
> the constant value 1 out of range. We should do range reduction to
> be able to process arbitrary values. Use a FRACT instruction after
> normalization to achieve this.
There is code in R600ISelLowering.cpp that does something similar:
R600TargetLowering::LowerTrig(). Could we re-use that code here, or
implement something similar is SIISelLowering.cpp?
- Tom
> ---
> lib/Target/R600/SIInstructions.td | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lib/Target/R600/SIInstructions.td b/lib/Target/R600/SIInstructions.td
> index f888b8e..2bdcfd2 100644
> --- a/lib/Target/R600/SIInstructions.td
> +++ b/lib/Target/R600/SIInstructions.td
> @@ -2253,12 +2253,12 @@ def : Pat<
>
> def : Pat <
> (fcos f32:$src0),
> - (V_COS_F32_e32 (V_MUL_F32_e32 $src0, (V_MOV_B32_e32 CONST.TWO_PI_INV)))
> + (V_COS_F32_e32 (V_FRACT_F32_e32(V_MUL_F32_e32 $src0, (V_MOV_B32_e32 CONST.TWO_PI_INV))))
> >;
>
> def : Pat <
> (fsin f32:$src0),
> - (V_SIN_F32_e32 (V_MUL_F32_e32 $src0, (V_MOV_B32_e32 CONST.TWO_PI_INV)))
> + (V_SIN_F32_e32 (V_FRACT_F32_e32(V_MUL_F32_e32 $src0, (V_MOV_B32_e32 CONST.TWO_PI_INV))))
> >;
>
> def : Pat <
> --
> 1.8.3.2
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list