是Add 1比真快INC? 86 [英] Is ADD 1 really faster than INC ? x86
问题描述
我已阅读,声称ADD 1比86使用INC更快的各种优化指南。这是真的吗?
I have read various optimization guides that claim ADD 1 is faster than using INC in x86. Is this really true?
推荐答案
在一些微架构,具有一定的指令流, INC
将收取部分标志更新摊位(因为它更新一些标志,同时preserving其他)。 添加
将所有标志的价值,因此不冒这样的摊位。
On some micro-architectures, with some instruction streams, INC
will incur a "partial flags update stall" (because it updates some of the flags while preserving the others). ADD
sets the value of all of the flags, and so does not risk such a stall.
添加
并不总是比 INC
更快,但它几乎总是至少快(有某些旧的微架构少数极端情况,但他们是极其罕见),有时显著更快。
ADD
is not always faster than INC
, but it is almost always at least as fast (there are a few corner cases on certain older micro-architectures, but they are exceedingly rare), and sometimes significantly faster.
有关详细信息,请参阅Intel's优化参考手册或瓦格纳雾的微架构说明。
For more details, consult Intel's Optimization Reference Manual or Agner Fog's micro-architecture notes.
这篇关于是Add 1比真快INC? 86的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!