[Mesa-dev] [PATCH] glsl: Use a separate div_to_mul_rcp lowering flag for integers.

Eric Anholt eric at anholt.net
Sun Aug 28 17:38:22 PDT 2011


On Sat, 27 Aug 2011 20:18:55 -0700, Kenneth Graunke <kenneth at whitecape.org> wrote:
> From: Bryan Cain <bryancain3 at gmail.com>
> 
> Using multiply and reciprocal for integer division involves potentially
> lossy floating point conversions.  This is okay for older GPUs that
> represent integers as floating point, but undesirable for GPUs with
> native integer division instructions.
> 
> TGSI, for example, has UDIV/IDIV instructions for integer division,
> so it makes sense to handle this directly.  Likewise for i965.
> 
> Signed-off-by: Bryan Cain <bryancain3 at gmail.com>
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>


> ---
>     case ir_binop_div:
> -      if (lowering(DIV_TO_MUL_RCP))
> +      if (lowering(INT_DIV_TO_MUL_RCP) && ir->operands[1]->type->is_integer())
> +	 int_div_to_mul_rcp(ir);
> +      else if (lowering(DIV_TO_MUL_RCP))
>  	 div_to_mul_rcp(ir);
>        break;
>  

Sure looks odd to me for one of these to be checking the type and ther
other not.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20110828/a411f304/attachment.pgp>


More information about the mesa-dev mailing list