I'm trying to understand the VEX prefix encoding for the SSE/AVX instructions. So please bear with me if I ask something simple. I have the following related questions.
Let's take the MOVUP(D/S) instruction (0F 10
). If I follow the 2-byte VEX prefix encoding correctly:
The following two instruction encodings produce the same result:
db 0fh, 10h, 00000000b ; movups xmm0,xmmword ptr [rax]
db 0c5h, 11111000b, 10h, 00000000b ; vmovups xmm0,xmmword ptr [rax]
As these two:
db 066h, 0fh, 10h, 00000000b ; movupd xmm0,xmmword ptr [rax]
db 0c5h, 11111001b, 10h, 00000000b ; vmovupd xmm0,xmmword ptr [rax]
Thus my questions:
What does the first v
stand for in those instructions? Is it just to denote the use of the VEX
prefix?
Does it make any difference (with the exception of the length of the instructions) if I use or don't use the VEX
prefix in the examples above?
I'm trying to understand Intel's syntax in their documentation. Say, this screenshot:
In VEX.128.0F.WIG
I can see that .128
is the bit 2 (L
) of the 2nd VEX
byte. Then .0F
is for a 3-byte VEX
prefix, m-mmmm
form to be 00001
, right? But what does the WIG
part stand for?
Is VEX
prefix recognized by the Intel CPUs only? How about AMD?
Lastly, what is the difference between movups
and movupd
? It seems like both of them simply move 16 bytes from the source memory:
into the xmm
register:
and the "double" or "single" precision packing really doesn't make any difference.
Thanks for your patience with me.
- What does the first v stand for in those instructions? Is it just to denote the use of the VEX prefix?
v stands for the AVX version of the instruction.
- Does it make any difference (with the exception of the length of the instructions) if I use or don't use the VEX prefix in the examples above?
Yes, it does. If you use the VEX prefix, upper bits of the register are cleared. (e.g. if you use vmovups xmm0, the upper half ymm0 is cleared.
- I'm trying to understand Intel's syntax in their documentation. [snip]. But what does the WIG part stand for?
"W" = width flag. "IG" = ignored.
From section "3.1.1.2 Opcode Column in the Instruction Summary Table (Instructions with VEX prefix)" in the manual,
"— WIG: can use C5H form (if not requiring VEX.mmmmm) or VEX.W value is ignored in the C4H form of VEX prefix."
"— If WIG is present, the instruction may be encoded using either the two-byte form or the three-byte form of VEX. When encoding the instruction using the three-byte form of VEX, the value of VEX.W is ignored."
- Is VEX prefix recognized by the Intel CPUs only? How about AMD?
It is recognized by any CPU that supports AVX. Both Intel and AMD have supported it since ~2011 (Intel's Sandy Bridge and later, and AMD's Bulldozer and later)
- Lastly, what is the difference between movups and movupd? It seems like both of them simply move 16 bytes from the source memory:
I believe that some processors may maintain flags on the contents of floating point SIMD registers; and using the wrong width/type may cause a stall in some situations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With