为什么SSE/AVX缺乏直接价值的负载?
据我所知,SSE/AVX中没有任何指示可以立即加载。一个解决方法是将值加载到普通寄存器和movd
,但是编译器似乎认为这比单个标量值即使从内存中加载也要成本高昂。
这使得每次使用通用常数进行操作,例如1
,0x80000000
,0x7ffffffff
,0x3f800000
,这使得需要内存访问。 ,0x3f000000
等。好吧,在机器代码中编码这些值的每个值将占用4个字节,但是32位绝对或RIP
relalative地址和我相信立即负载比任何形式的内存负载便宜。
我一直以为movs xmm,imm32
或广播XMM,IMM32
很高兴拥有,但是必须有一个理由不做此类说明。为什么设计这种方式?
As far as I know, there is no instruction in SSE/AVX for loading an immediate. One workaround is loading a value to a normal register and movd
, but compilers seem to think this is more costly than loading from memory even for a single scalar value.
This makes memory access necessary every time doing an operation with common constants such as 1
, 0x80000000
, 0x7fffffff
, 0x3f800000
, 0x3f000000
, etc. Well, having these values encoded in the machine code will occupy 4 bytes each, but so does a 32-bit absolute or rip
-relative address, and I believe an immediate load is cheaper than any sort of memory load.
I always thought something like movss xmm, imm32
or broadcastss xmm, imm32
would be nice to have, but there must be a reason for not making such instructions. Why was it designed this way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论