On Sun, 28 Aug 2011 20:51:10 -0500, Bryan Cain <bryanca...@gmail.com> wrote:
> On 08/28/2011 07:38 PM, Eric Anholt wrote:
> > On Sat, 27 Aug 2011 20:18:55 -0700, Kenneth Graunke <kenn...@whitecape.org> 
> > wrote:
> >> From: Bryan Cain <bryanca...@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 <bryanca...@gmail.com>
> >> Signed-off-by: Kenneth Graunke <kenn...@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.
> 
> It works, though.  If it's not an integer type, it's going to be a float
> type.

Not to my reading.  If ir->op[1]->type->is_integer() &&
!lowering(INT_DIV_TO_MULL_RCP) && lowering(DIV_TO_MUL_RCP), then
assert(ir->operands[1]->type->is_float()) should fail.

Attachment: pgpD2YZnGOLZ6.pgp
Description: PGP signature

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to