[Mesa-dev] [PATCH 5/5] glsl: Improve the local dead code optimization to eliminate unused channels.

Ian Romanick idr at freedesktop.org
Wed May 9 08:46:30 PDT 2012


On 05/08/2012 05:59 PM, Eric Anholt wrote:
> Total instructions: 261582 ->  261316
> 135/2147 programs affected (6.3%)
> 36752 ->  36486 instructions in affected programs (0.7% reduction)
>
> This excludes a tropics shader that now gets 16-wide mode and throws
> off the numbers.  5 shaders are hurt: two extra MOVs in 4 tropics
> shaders it looks like because we don't split register names according
> to independent webs, and one gstreamer shader where it looks like
> try_rewrite_rhs_to_dst() is falling on its face.
>
> This should also help avoid a regression in VSes from idr's ARB
> programs to GLSL work.

Sort of, but not really.  It seems to change cases like

    (assign  (xyzw) (var_ref gl_TexCoord[5])  (constant vec4 (0.000000 
0.500000 0.000000 1.000000)) )
mov(8)          m10<1>.xzF      0F                              { 
align16 WE_normal 1Q };
mov(8)          m10<1>.yF       0.5F                            { 
align16 WE_normal 1Q };
mov(8)          m10<1>.wF       1F                              { 
align16 WE_normal 1Q };
    (assign  (x) (var_ref gl_TexCoord[5])  (expression float dot 
(var_ref vertex_attrib8) (var_ref gl_Env14) ) )
dp4(8)          m10<1>.xF       g12<4,4,1>F     g5<0,4,1>F      { 
align16 WE_normal 1Q };

into

    (assign  (zw) (var_ref gl_TexCoord[5])  (constant vec2 (0.000000 
1.000000)) )
mov(8)          g16<1>.xF       0F                              { 
align16 WE_normal 1Q };
mov(8)          g16<1>.yF       1F                              { 
align16 WE_normal 1Q };
mov(8)          m10<1>.zwF      g16<4,4,1>.yyxyF                { 
align16 WE_normal 1Q };
    (assign  (x) (var_ref gl_TexCoord[5])  (expression float dot 
(var_ref vertex_attrib8) (var_ref gl_Env14) ) )
dp4(8)          m10<1>.xF       g12<4,4,1>F     g5<0,4,1>F      { 
align16 WE_normal 1Q };

The extra load of 0.5 is eliminated (yay), but now the immediate values 
are loaded into an extra temporary (boo) resulting in the same total 
number of instructions.


More information about the mesa-dev mailing list