lwip-devel
[Top][All Lists]
Advanced

[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:1.8.0.12) Gecko/20070530 Fedora/1.5.0.12-1.fc5 Firefox/1.5.0.12

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:

  <http://savannah.nongnu.org/task/?6827>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/





reply via email to

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