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

Tom Stellard tstellar at gmail.com
Fri Apr 8 00:32:09 PDT 2011


On Thu, Apr 07, 2011 at 03:51:40AM +0000, 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.
> 
> > +/**
> > + * 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.
>

All occurrences of TO (tee oh) are typos.  It should be T0 (tee zero) everywhere.

-Tom


More information about the mesa-dev mailing list