[Mesa-dev] Case where opt_copy_propagation doesn't do its job
Eric Anholt
eric at anholt.net
Tue Jul 12 14:36:11 PDT 2011
On Tue, 12 Jul 2011 15:44:12 -0500, Bryan Cain <bryancain3 at gmail.com> wrote:
> It appears that the copy propagation pass in the GLSL compiler (in
> opt_copy_propagation.cpp) doesn't do copy propagation when the
> components of a variable are initialized separately, like this:
>
> (declare (temporary ) vec4 vec_ctor)
> (assign (w) (var_ref vec_ctor) (constant float (1.000000)) )
> (assign (xyz) (var_ref vec_ctor) (var_ref assignment_tmp at 16) )
> (assign (xyzw) (var_ref gl_FragColor) (var_ref vec_ctor) )
>
> In the past, this wasn't visible in the Mesa IR output because Mesa IR
> optimization seems to do the copy propagation. However, glsl_to_tgsi
> doesn't do copy propagation to output registers - in fact, I believe
> this is the only case left where ir_to_mesa produces better code than
> glsl_to_tgsi. I'm not very enthusiastic about the idea adding to the
> copy propagation pass in glsl_to_tgsi, since this case is something that
> should really be optimized by the GLSL compiler before it reaches the IR
> backend.
>
> So, is there a reason why the GLSL copy propagation pass doesn't operate
> per-component?
opt_copy_propagation_elements does that, but it doesn't split up the
assignment into multiple assignments (otherwise, imagine initializing
vec_ctor once and using it many times -- how do you decide whether copy
propagate or not, to avoid pessimizing the code?).
I think the operation you're looking for isn't really copy propagation,
but more like register coalescing where you see that vec_ctor doesn't
get redefined and used after being assigned to gl_FragColor, and just
store the two in the same place. And yes, I think it would be useful to
have something like that.
Either that or generate new ir_quadop_vector in copy propagation.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20110712/3e64cc49/attachment.pgp>
More information about the mesa-dev
mailing list