Under 64 bit x86 CPU normally we load number -1 in to register like:
mov rdx, -1 // 48BAFFFFFFFFFFFFFFFF
... this opcode takes 10 bytes.
Another way is:
xor rdx, rdx // 4831D2
dec rdx // 48FFCA
... this opcode takes only 6 bytes.
EDIT:
As Jens Björnhager say (I have tested) xor edx, edx opcode should clear whole rdx register:
xor edx, edx // 31D2
dec rdx // 48FFCA
... this opcode takes only 5 bytes.
EDIT:
Alex find another solution:
mov rdx, -1 // 48C7C2FFFFFFFF
... this opcode takes only 7 bytes. But how to tell compiler to use shorter opcode (without using DB)?
...
What is faster and what is more economical?