VEX前缀编码和SSE/AVX MOVUP(D/S)指令 [英] VEX prefixes encoding and SSE/AVX MOVUP(D/S) instructions
问题描述
我试图了解SSE/AVX指令的VEX前缀编码.所以,如果我问一些简单的问题,请多多包涵.我有以下相关问题.
让我们采用
以下两种指令编码产生相同的结果:
db 0fh,10h,00000000b;movups xmm0,xmmword ptr [rax]db 0c5h,11111000b,10h,00000000b;vmovups xmm0,xmmword ptr [rax]
这两个:
db 066h,0fh,10h,00000000b;movupd xmm0,xmmword ptr [rax]db 0c5h,11111001b,10h,00000000b;vmovupd xmm0,xmmword ptr [rax]
我的问题是
-
第一个
v
在这些说明中代表什么?仅仅是表示使用VEX
前缀吗? -
如果我在上面的示例中使用或不使用
VEX
前缀,除了说明的长度之外,它有什么区别吗? -
我正在尝试了解
在
VEX.128.0F.WIG
中,我看到.128
是第二个的第2位(
字节.那么L
)VEX.0F
是3字节的VEX
前缀,m-mmmm
的格式为00001
,对吗?但是WIG
部分代表什么?-
VEX
前缀仅被Intel CPU识别吗?那么AMD呢? -
最后,
movups
和movupd
有什么区别?似乎他们两个都只是简单地从源内存中移出了16个字节:
进入
xmm
寄存器:双精度"或单精度"打包确实没有任何区别.
感谢您对我的耐心.
解决方案- 这些说明中的第一个v代表什么?仅仅是表示使用VEX前缀吗?
v代表指令的AVX版本.
- 如果我在上面的示例中使用或不使用VEX前缀,除了说明的长度之外,这有什么区别吗?
是的,确实如此.如果使用VEX前缀,则将清除寄存器的高位.(例如,如果您使用vmovups xmm0,则会清除ymm0的上半部分.
- 我试图在他们的文档中了解Intel的语法.[片段].但是WIG部分代表什么?
"W" =宽度标志."IG" =已忽略.
从手册的指令摘要表中的3.1.1.2操作码列(带VEX前缀的指令)"开始,
"— WIG:可以使用C5H形式(如果不需要VEX.mmmmm),或者VEX.W值在VEX前缀的C4H形式中被忽略."
-如果存在WIG,则可以使用VEX的两字节形式或三字节形式对指令进行编码.使用VEX的三字节形式对指令进行编码时,VEX.W的值被忽略."
- VEX前缀仅被Intel CPU识别吗?那么AMD呢?
任何支持AVX的CPU均可识别.自2011年以来,英特尔和AMD都一直对此提供支持(英特尔的Sandy Bridge和更高版本,以及AMD的Bulldozer和更高版本)
- 最后,movup和movupd有什么区别?似乎他们两个都只是从源内存中移出了16个字节:
我相信某些处理器可能会在浮点SIMD寄存器的内容上保留标志;在某些情况下使用错误的宽度/类型可能会导致停顿.
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 theVEX
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 2ndVEX
byte. Then.0F
is for a 3-byteVEX
prefix,m-mmmm
form to be00001
, right? But what does theWIG
part stand for?Is
VEX
prefix recognized by the Intel CPUs only? How about AMD?Lastly, what is the difference between
movups
andmovupd
? 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.
这篇关于VEX前缀编码和SSE/AVX MOVUP(D/S)指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
-