Robert Dewar - Re: GCC-generated code and i386 condition codes behavior (original) (raw)

This is the mail archive of the gcc@gcc.gnu.orgmailing list for the GCC project.

Robert Dewar dewar@adacore.com writes:

I must say I am a bit surprised that gcc never takes advantage of the fact that inc and dec do not destroy the carry flag, this is quite significant for some loops.

A lot of this old wisdom is no longer true.

inc and dec are to be generally avoided these days, because the partial changing of EFLAGS causes too strict dependencies on Intel P4 cores and threefore slower execution. It's better to use add/sub $1,... instead, except if you're optimizing for code size.