I have read various optimization guides that claim ADD 1 is faster than using INC in x86. Is this really true?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
On some micro-architectures, with some instruction streams,
INCwill incur a “partial flags update stall” (because it updates some of the flags while preserving the others).ADDsets the value of all of the flags, and so does not risk such a stall.ADDis not always faster thanINC, 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.For more details, consult Intel’s Optimization Reference Manual or Agner Fog’s micro-architecture notes.