[Mesa-dev] [PATCH] glsl: Use a separate div_to_mul_rcp lowering flag for integers.
Ian Romanick
idr at freedesktop.org
Mon Aug 29 10:50:54 PDT 2011
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 08/28/2011 06:51 PM, Bryan Cain wrote:
> On 08/28/2011 07:38 PM, Eric Anholt wrote:
>> 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.
>
> It works, though. If it's not an integer type, it's going to be a float
> type.
Right, but it could be an integer type and !lower(INT_DIV_TO_MUL_RCP).
In which case if lower(DIV_TO_MUL_RCP), do_to_mul_rcp will get called on
an integer type. Right?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iEYEARECAAYFAk5b0X4ACgkQX1gOwKyEAw+IEQCfV1mHz5ZrwLMvPpbAzAGdlorg
zNcAn2iMVg8U7J5BVGiRugikqKYI5D7C
=myKt
-----END PGP SIGNATURE-----
More information about the mesa-dev
mailing list