lkml.org 
[lkml]   [1999]   [Jan]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: Structure vs purism ?
Date
>>>>> "Richard" == Richard B Johnson <root@chaos.analogic.com> writes:
> Maybe, one function at a time --one carefully checked function at a time.
> For instance, the way we were 'taught` to write code (by instuctors and
> professors who never built actual products, BTW) goes something like
> this...
[.. ugly nested ifs ..]
> ..... produces absolutely rotten code on every compiler I've ever
> used. This is because it jumps on the normal-flow condition.

Have you tried to compile, profile and then recompile with the profile info fed
back to the compiler ? I think such a 3-step process is what Philipp Rumpf
had in mind when he said:

I think a lot of the goto's could be removed as soon as there is a decent
possibility to tell the compiler to optimize for a certain case. This was
discussed on the egcs lists some time ago IIRC.

> compare against a final value because on most/many/(all?) processors
> the flags change automatically when decrementing to zero or decrementing
> to a negative number.

MIPS and Alpha don't have `flags'. But I still agree that it's most of the
time cheaper to check against 0 than against any other value.

> while(i--)
> ;
> However, gcc will usually mess with this and end up decrementing a
> value on the stack or in the register-variable case, add extra code.

I believe the problem of stack allocating such loop variables is fairly
specific to register-starved machines such as the i386. And the `extra code'
is also fairly architecture dependent.


Stefan

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:49    [from the cache]
©2003-2011 Jasper Spaans