mov%rax,%rax 的目的是什么?
我目前正在通过反汇编一些C代码来学习ASM。我感兴趣的一件事是 gcc 编译器生成这样的代码,
movq %rax,%rax
这显然毫无意义。那么这样做的目的是什么呢?
我想知道是否是为了浪费几个CPU周期来改善管道?
谢谢你的提示!
I am currently learning ASM by disassembling some of C codes. One thing interested me is that the gcc compiler generates code like this
movq %rax,%rax
which is obviously meaningless. So what is the purpose of doing that?
I am wondering if it is used for waste a few cycles of CPU in order to improve the pipeline?
Thank you for your hint!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,这基本上是一个无操作。
编译器这样做是因为分支到在 4 字节边界上对齐的地址比分支到未对齐的地址更快。因此,如果有循环,编译器将在循环开始之前插入“填充”,以便使其对齐。
It is basically a no-op, yes.
The compiler does this because branching to an address aligned on a 4-byte boundary is faster than branching to an unaligned address. So if you have a loop, the compiler will insert "padding" just before the start of it in order to get it into alignment.