what's the best way to toggle simd register

Programming, for all ages and all languages.
Post Reply
blackoil
Member
Member
Posts: 146
Joined: Mon Feb 12, 2007 4:45 am

what's the best way to toggle simd register

Post by blackoil »

toggle xmm0: //cost 2 instructions, 2 registers
vpcmpeqd xmm1,xmm1,xmm1
vpcmpeqd xmm0,xmm0,xmm1

is there single instruction method?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

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

Post 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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
blackoil
Member
Member
Posts: 146
Joined: Mon Feb 12, 2007 4:45 am

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

Post by blackoil »

it should be

Code: Select all

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