Page 1 of 1

what's the best way to toggle simd register

Posted: Sun Dec 21, 2014 4:51 am
by blackoil
toggle xmm0: //cost 2 instructions, 2 registers
vpcmpeqd xmm1,xmm1,xmm1
vpcmpeqd xmm0,xmm0,xmm1

is there single instruction method?

Re: what's the best way to toggle simd register

Posted: Sun Dec 21, 2014 5:05 am
by Combuster
By using a memory operand pointing to a constant (pxor to all ones would be the most obvious). Actually inverting the preceding test so you don't need this in the first place would be a much better idea though ;)

You currently appear to be doing

Code: Select all

x = (x == true) ? true : false;
instead of false : true, so it doesn't actually toggle anything.

Re: what's the best way to toggle simd register

Posted: Sun Dec 21, 2014 8:11 am
by blackoil
it should be

Code: Select all

vpcmpeqd xmm1,xmm1,xmm1
vpxor xmm0,xmm0,xmm1
I wonder why there isn't vpnot instruction.