[Mesa-dev] [PATCH 1/3] i965/vec4: Call opt_algebraic after opt_cse.

Matt Turner mattst88 at gmail.com
Tue Sep 30 14:16:57 PDT 2014


On Tue, Sep 30, 2014 at 2:10 PM, Ian Romanick <idr at freedesktop.org> wrote:
> On 09/27/2014 12:12 PM, Matt Turner wrote:
>> The next patch adds an algebraic optimization for the pattern
>>
>>    sqrt a, b
>>    rcp  c, a
>>
>> and turns it into
>>
>>    sqrt a, b
>>    rsq  c, b
>>
>> but many vertex shaders do
>>
>>    a = sqrt(b);
>>    var1 /= a;
>>    var2 /= a;
>>
>> which generates
>>
>>    sqrt a, b
>>    rcp  c, a
>>    rcp  d, a
>>
>> If we apply the algebraic optimization before CSE, we'll end up with
>>
>>    sqrt a, b
>>    rsq  c, b
>>    rcp  d, a
>
> Why doesn't a second pass through opt_algebraic turn this into

Because the addition in patch #2 just recognizes a consecutive sqrt+rcp pattern.

>    rsq  c, b
>    rsq  d, b
>
> Seems like this could cause us to miss other optimization opportunities...

This seems pretty sufficient for the collection of shaders in
shader-db -- no regressions, cuts vec4 instructions, and handles 410
sqrt+rcp pairs.


More information about the mesa-dev mailing list