Andi Kleen wrote:
Robert Dewar <[EMAIL PROTECTED]> 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.

actually as Geert points out, probably LEA is the right choice
when you don't want to affect the flags, though in this case
I guess you need some otherway to test for loop termination.
Not clear how you do that without destroying the carry flag.
I will do some benchmarks in this area to see how the old
wisdom holds :-)

-Andi


Reply via email to