[Mesa-dev] [PATCH 1/5] glsl/cse: Use ir_rvalue_enter_visitor instead of ir_rvalue_visitor

Ian Romanick idr at freedesktop.org
Thu Apr 9 14:48:55 PDT 2015


On 04/09/2015 02:40 PM, Kenneth Graunke wrote:
> On Wednesday, April 08, 2015 04:38:27 PM Ian Romanick wrote:
>> From: Ian Romanick <ian.d.romanick at intel.com>
>>
>> ir_rvalue_visitor visits each rvalue on exit.  When visiting a large
>> expression, the leaf expressions will be visited and eliminated first.
>> Once one leaf expression was replaced, it would no longer match a
>> potentially much larger tree.  This means that code like:
>>
>>     x = a + (b * c);
>>     y = -(a + (b * c));
>>
>> would effectively be replaced by
>>
>>     tmp = b * c;
>>     x = a + tmp;
>>     y = -(a + tmp);
>>
>> As a result both opportunities for generating a MAD would be lost, and
>> we would generate worse code.
>>
>> Using ir_rvalue_enter_visitor means that larger expression trees will be
>> checked first, and we have the potential to eliminate much larger
>> expressions.
>>
>> I believe that opt_cse.cpp predates the existence of
>> ir_rvalue_enter_visitor.
> 
> I'm still concerned about this patch.  It means that for every node in
> the expression tree, we have to traverse its subtree.
> 
> It seems like that could increase the CPU cost of this pass
> considerably.  I suppose many nodes end up comparing not-equal fairly
> quickly...

That is a distinct possibility.  Is there some data that you would like
me to collect to either ease or confirm these concerns?  Difference in
time of a shader-db run?



More information about the mesa-dev mailing list