Bug 86161

Summary: Calculation result with only uniform inputs uses too much register space
Product: Mesa Reporter: Petri Latvala <petri.latvala>
Component: Drivers/DRI/i965Assignee: Ian Romanick <idr>
Status: RESOLVED MOVED QA Contact: Intel 3D Bugs Mailing List <intel-3d-bugs>
Severity: normal    
Priority: medium CC: eero.t.tamminen
Version: git   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Bug Depends on:    
Bug Blocks: 77547    

Description Petri Latvala 2014-11-11 15:46:43 UTC
uniform float ux;
uniform float uy;

void main()
{
  float x = ux * uy;
  gl_FragColor = vec4(x * 0.5);
}



This fragment shader yields the following assembly:

SIMD8 shader: 7 instructions. Compacted 112 to 80 bytes (29%)
   START B0
   (assign  (xyzw) (var_ref gl_FragColor)  (swiz xxxx (expression float * (expression float * (var_ref ux) (var_ref uy) ) (constant float (0.500000)) ) )) 
mul(8)          g3<1>F          g2<0,1,0>F      g2.1<0,1,0>F    { align1 1Q compacted };
mul(8)          g4<1>F          g3<8,8,1>F      0.5F            { align1 1Q };
   FB write target 0
mov(8)          g113<1>F        g4<8,8,1>F                      { align1 1Q compacted };
mov(8)          g114<1>F        g4<8,8,1>F                      { align1 1Q compacted };
mov(8)          g115<1>F        g4<8,8,1>F                      { align1 1Q compacted };
mov(8)          g116<1>F        g4<8,8,1>F                      { align1 1Q compacted };
nop                                                             ;
sendc(8)        null            g113<8,8,1>F
                            render RT write SIMD8 LastRT Surface = 0 mlen 4 rlen 0 { align1 1Q EOT };
   END B0


In particular, the first instruction:
mul(8)          g3<1>F          g2<0,1,0>F      g2.1<0,1,0>F    { align1 1Q compacted };

The operands are the two uniform values in subregisters g2.0 and g2.1. The written register region is the whole g3 with exec size 8, where a single float with exec size 1 would suffice.

Of course just changing the above instruction to exec size 1 would achieve nothing if the register allocator is not improved to benefit from the leftover space...
Comment 1 GitLab Migration User 2019-09-25 18:52:46 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/mesa/mesa/issues/1461.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.