VEX prefixes encoding and SSE/AVX MOVUP(D/S) instructions

Deadly 提交于 2021-02-07 13:50:22

问题


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:

  1. What does the first v stand for in those instructions? Is it just to denote the use of the VEX prefix?

  2. 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?

  3. 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?

  1. Is VEX prefix recognized by the Intel CPUs only? How about AMD?

  2. 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.


回答1:


  1. 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.

  1. 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.

  1. 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."

  1. 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)

  1. 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.



来源:https://stackoverflow.com/questions/51773399/vex-prefixes-encoding-and-sse-avx-movupd-s-instructions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!