[Mesa-dev] [PATCH 3/3] i965/fs: Drop no-op shifts involving 0.

Eric Anholt eric at anholt.net
Mon Oct 28 22:06:29 CET 2013


Matt Turner <mattst88 at gmail.com> writes:

> On Fri, Oct 25, 2013 at 2:49 PM, Eric Anholt <eric at anholt.net> wrote:
>> I noticed this in a shader in Unigine Heaven that was spilling.  While it
>> doesn't really reduce register pressure, it shaves a few instructions
>> anyway (7955 -> 7882).
>>
>> v2: Fix turning "0 >> x" into "x" instead of "0" (caught by Erik
>>     Faye-Lund).
>> ---
>>  src/glsl/opt_algebraic.cpp | 10 ++++++++++
>>  1 file changed, 10 insertions(+)
>>
>> diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp
>> index 2e33dfe..a07e153 100644
>> --- a/src/glsl/opt_algebraic.cpp
>> +++ b/src/glsl/opt_algebraic.cpp
>> @@ -346,6 +346,16 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
>>        }
>>        break;
>>
>> +   case ir_binop_rshift:
>> +   case ir_binop_lshift:
>> +      /* 0 >> x == 0 */
>> +      if (is_vec_zero(op_const[0]))
>> +         return ir->operands[0];
>
> Any value to writing ir_constant::zero(ir, ir->type) here instead?

More allocation instead of less, seems silly.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20131028/4db234d4/attachment.pgp>


More information about the mesa-dev mailing list