将旧的SSE编码指令和VEX编码的指令混合在同一代码路径中可以吗?

编程入门 行业动态 更新时间:2024-10-16 18:36:15
本文介绍了将旧的SSE编码指令和VEX编码的指令混合在同一代码路径中可以吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

随着AVX的推出,英特尔将VEX编码方案引入了Intel 64和IA-32架构.此编码方案通常与AVX指令一起使用.我想知道是否可以混合使用VEX编码的指令和现在称为旧版SSE"的指令.

Along with the introduction of AVX, Intel introduced the VEX encoding scheme into the Intel 64 and IA-32 architecture. This encoding scheme is used mostly with AVX instructions. I was wondering if it's okay to intermix VEX-encoded instructions and the now called "legacy SSE" instructions.

我问这个问题的主要原因是代码大小.考虑以下两个说明:

The main reason for me asking this question is code size. Consider these two instructions :

shufps xmm0, xmm0, 0 vshufps xmm0, xmm0, xmm0, 0

我通常使用第一个将标量值广播"到XMM寄存器中的所有位置.现在,指令集说这两者(在这种情况下)的唯一区别是VEX编码的指令清除了YMM寄存器的高位(> = 128).假设我不需要,在这种情况下使用VEX编码的版本有什么优势?第一条指令占用4个字节(0FC6C000),第二条指令占用5个字节(C5F8C6C000).

I commonly use the first one to "broadcast" a scalar value to all the places in an XMM register. Now, the instruction set says that the only difference between these two (in this case) is that the VEX-encoded one clears the higher (>=128) bits of the YMM register. Supposing that I don't need that, what's the advantage of using the VEX-encoded version in this case? The first instruction takes 4 bytes (0FC6C000), the second - 5 (C5F8C6C000).

感谢所有答案.

推荐答案

在当前实现中,如果(至少)上半部分已重置(VZEROUPPER或VZEROALL),则使用旧版SSE指令不会受到任何惩罚.

On current implementations, if (at least) the upper halves have been reset (VZEROUPPER or VZEROALL) there is no penalty for using legacy SSE instructions.

如第128页中的 Agner Fog:使用旧版优化子程序中所述使用(某些)上半部分时的SSE指令会降低性能.当进入YMM寄存器在中间被分开的状态时,将产生这种惩罚,而当离开该状态时,将再次引起这种惩罚.

As detailed on page 128 in Agner Fog: optimizing subroutines in assembly, using legacy SSE instructions while (some) upper halves are in use carries a performance penalty. This penalty is incurred once when entering the state where YMM registers are split in the middle, and once again when leaving that state.

混合使用VEX编码的128位指令和旧版SSE指令不是问题.

Mixing VEX-encoded 128-bit instructions and legacy SSE instructions is not a problem.

更多推荐

将旧的SSE编码指令和VEX编码的指令混合在同一代码路径中可以吗?

本文发布于:2023-11-17 02:38:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1608503.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:指令   路径   代码   在同一   SSE

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!