[Mesa-dev] Case where opt_copy_propagation doesn't do its job

Bryan Cain bryancain3 at gmail.com
Tue Jul 12 13:44:12 PDT 2011

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

So, is there a reason why the GLSL copy propagation pass doesn't operate


More information about the mesa-dev mailing list