[Top][All Lists]

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

Re: [Chicken-users] two minor tweaks to runtime.c

From: Alan Post
Subject: Re: [Chicken-users] two minor tweaks to runtime.c
Date: Tue, 27 Sep 2011 13:28:45 -0601

On Tue, Sep 27, 2011 at 09:21:15PM +0200, Jörg F. Wittenberger wrote:
> On Sep 27 2011, Peter Bex wrote:
> >On Tue, Sep 27, 2011 at 03:22:06PM +0200, Jörg F. Wittenberger wrote:
> >>While I've been looking at the code I wondered if the C compiler
> >>will fur sure pull that one test out of the for-loop.
> >>
> >>Maybe it's better no have it there at the first place.
> >>IMHO the code is not more confusing to read this way and should
> >>run better in case the C compiler is not smart enough.
> >
> >I'm firmly opposed to any such change that makes the code
> >much less readable for very little gain.
> Please excuse me objecting.
> IMHO the code is not less readable the rewritten way.
> In fact - and so far it's a matter of taste - I would find it less
> confusing.  (Let alone that it's fewer instructions.)
> However I'm quite old school.  If I can tell the compiler something
> and not rely on the compilers cleverness, I'll do so.  (And NOT do so
> iff I want to create a test case for the compiler.)
> In the case at hand I applied something which would have been typical
> educational example in the late 70th: pull conditionals out of
> frequently executed code if you can.
> Is there anybody on the list who has a test case at hand, which would
> exercise cons/list operations or initialisation code?  (Mine would be
> suspicious in this case.)  Looking at "alternativ" compilers (besides
> gcc) would be very nice.
> The chance, which - depending on taste, would make the code either more
> comprehensible or less - could have an actual effect.  That would be
> the final argument in my case.

FWIW I agree with Jörg'sreasoning.  I've spend a fair bit of my C
programming time removing conditional code from loops.  It has been
a few years since I tested, but when I was actively writing C code,
removing opportunities for the branch predictor to fail measurably
sped up code.

I don't have enough data to say that it matters in this case, but in
principle it surely does.  Jörg's code is "obvious" to me in the
manner of "ah, that's removing a conditional from inside the for

BTW, I've loved reading the comments and patches suddenly flying
around the mailing list.  I'm learning a lot about Chicken and am
particularly interested to see which parts of the system apparently
receive attention and which aren't being changed. 

.i ma'a lo bradi cu penmi gi'e du

reply via email to

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