On Mon, May 19, 2014 at 10:56 AM, Aras Pranckevicius <a...@unity3d.com> wrote: > Hi, > > When Mesa's GLSL compiler is faced with a code like this: > > // vec4 packednormal exists > vec3 normal; > normal.xy = packednormal.wy * 2.0 - 1.0; > normal.z = sqrt(1.0 - dot(normal.xy, normal.xy)); > // now do not use the "normal" at all anywhere > > Then the dead code elimination pass will not be able to eliminate the > "normal" variable, nor anything that lead to it (possibly sampling textures > into packed normal, etc.). > > This is because variable refcounting visitor sees "normal" as having four > references, but only two assignments, and can not consider it dead. Even if > these two references are from assignment to normal.z where both LHS & RHS > reference the same variable. > > Any ideas on how to improve this? > > > If the original code was doing something like this, then dead code > elimination is able to "properly" eliminate this whole thing: > > // vec4 packednormal exists > vec3 normal; > vec2 nxy = packednormal.wy * 2.0 - 1.0; > float nz = sqrt(1.0 - dot(nxy, nxy)); > normal.xy = nxy; > normal.z = nz; > // now do not use the "normal" at all anywhere
Eric is working on a better GLSL IR dead code elimination pass. I'm not sure of the current status. It's in his tree: git://people.freedesktop.org/~anholt/mesa deadcode _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev