[Mesa-dev] [PATCH] tgsi: Add a conditional move inststruction

Zack Rusin zackr at vmware.com
Thu Apr 4 09:06:44 PDT 2013


Hah, yea, I'm sorry, that's a good point. So movc is a bitcast to unsigned followed by ucmp. Alright, I'm withdrawing the patch.

z

----- Original Message -----
> 
> 
> ----- Original Message -----
> > > > Erm, unsigned < 0 doesn't make sense.
> > > 
> > > Ah indeed!
> > > 
> > > > Definitely what the description says:
> > > > static void
> > > > micro_ucmp(union tgsi_exec_channel *dst,
> > > >            const union tgsi_exec_channel *src0,
> > > >            const union tgsi_exec_channel *src1,
> > > >            const union tgsi_exec_channel *src2)
> > > > {
> > > >    dst->u[0] = src0->u[0] ? src1->u[0] : src2->u[0];
> > > >    dst->u[1] = src0->u[1] ? src1->u[1] : src2->u[1];
> > > >    dst->u[2] = src0->u[2] ? src1->u[2] : src2->u[2];
> > > >    dst->u[3] = src0->u[3] ? src1->u[3] : src2->u[3];
> > > > }
> > > > 
> > > > or
> > > > 
> > > >    case TGSI_OPCODE_UCMP:
> > > >    case TGSI_OPCODE_CMP:
> > > >       FOR_EACH_DST_ENABLED_CHANNEL(0, c, tgsi) {
> > > >          src0 = fetchSrc(0, c);
> > > >          src1 = fetchSrc(1, c);
> > > >          src2 = fetchSrc(2, c);
> > > >          if (src1 == src2)
> > > >             mkMov(dst0[c], src1);
> > > >          else
> > > >             mkCmp(OP_SLCT, (srcTy == TYPE_F32) ? CC_LT(less than 0) :
> > > > CC_NE(not equal 0),
> > > >                   srcTy, dst0[c], src1, src2, src0);
> > > >       }
> > > > 
> > > 
> > > But odd enough, the implementations I happend to look at seemed to do
> > > "foo
> > > >=
> > > 0":
> > 
> > Yea, like I mentioned it's pretty broken. Sometimes it's implemented as
> > UCMP,
> > sometimes it's implemented as MOVC.
> > It seems to be used only as MOVC.
> > It feels silly writing this, but we should probably make UCMP act like UCMP
> > and add MOVC and use it when we need a MOVC.
> 
> Zack, I believe Christoph has a point when he says that UCMP is semantically
> the same as MOVC.
> 
> Because for unsigned integers, "foo > 0" is the same as "foo != 0", therefore
> having UCMP defined as
> 
>   dst = src0 > 0 ? src1 : src2
> 
> or a MOVC as
> 
>   dst = src0 != 0 ? src1 : src2
> 
> is pretty much the same.
> 
> Jose
> 
> 


More information about the mesa-dev mailing list