[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-devel] [task #6827] etharp could need some tuning

From: Jonathan Larmour
Subject: [lwip-devel] [task #6827] etharp could need some tuning
Date: Tue, 19 Jun 2007 16:33:21 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/20070530 Fedora/ Firefox/

Follow-up Comment #39, task #6827 (project lwip):

It would be equivalent to:
 for (k=6;k>0;k--)
and (unless the compiler optimises it by itself, which it might), that is
typically faster than:
for (k = 0; k < 6; k++) { 

because it tends to be faster on processors to compare against 0, than
against a given constant. A constant adds to register pressure and has to be
maintained in a register, or saved/restored in memory at the end of each loop
for the check. Comparison against 0 can usually be done directly in a single
instruction (or if using CISC where both would be single instruction, it
would take fewer cycles).

Making your loops have a comparison against 0 does count as one of the more
obscure optimisations you can do though, I agree.


Reply to this item at:


  Message sent via/by Savannah

reply via email to

[Prev in Thread] Current Thread [Next in Thread]