[Mesa-dev] [PATCH 2/2] prog_optimize: Add simplify CMP optimization pass

Ian Romanick idr at freedesktop.org
Thu Apr 7 12:32:40 PDT 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 04/06/2011 08:51 PM, Matt Turner wrote:
> On Thu, Apr 7, 2011 at 3:06 AM, Tom Stellard <tstellar at gmail.com> wrote:
> 
> I don't know anything about this code, but I just want to verify that
> T0 (tee zero) and TO (tee oh) are different things and are used in the
> right places.

I think they're supposed to be the same.  That is, we should s/TO/T0/.
It has always seemed silly that o and 0 are so close on qwerty keyboards.

>> +/**
>> + * This pass replaces CMP T0, T1 T2 T0 with MOV TO, T2 when the CMP
>> + * instruction is the first instruction to write to register T0.  The are
>> + * several lowering passes done in GLSL IR (e.g. branches and
>> + * relative addressing) that create a large number of conditional assignments
>> + * that ir_to_mesa converts to CMP instructions like the one mentioned above.
>> + *
>> + * Here is why this conversion is safe:
>> + * CMP TO, T1 T2 T0 can be expanded to:
>> + * if (T1 < 0.0)
>> + *     MOV T0, T2;
>> + * else
>> + *     MOV T0, TO;
>> + *
>> + * If (T1 < 0.0) evaluates to true then our replacement MOV T0, T2 is the same
>> + * as the original program.  If (T1 < 0.0) evaluates to false, executing
>> + * MOV T0, T0 will store a garbage value in T0 since T0 is uninitialized.
>> + * Therefore, it doesn't matter that we are replacing MOV T0, T0 with MOV TO, T2
>> + * because any instruction that was going to read from T0 after this was going
>> + * to read a garbage value anyway.
> 
> I see "This pass replaces CMP T0, T1 T2 T0" but also "CMP TO, T1 T2 T0
> can be expanded to" where the first has T0 twice and the second has TO
> and T0. And a few other seemingly strange occurrences of TO also.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAk2eEVgACgkQX1gOwKyEAw/1PACdF9At3TGvBtpT0dlYi3+B+qSe
qdkAn0QSe5LG0sig3SZJbQLc+GQJBXbQ
=6Bll
-----END PGP SIGNATURE-----


More information about the mesa-dev mailing list