🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c.moderated
Article #2405

Re: use of the break statement

#2405
From: Falstaff
Date: Wed, 27 Mar 1996 12:33
36 lines
2156 bytes
tanmoy@qcd.Lanl.GOV (Tanmoy Bhattacharya) writes:

>>   do
>>     statement;  
>>   while (exp);
 
>>   label:
>>     statement;
>>   if (exp)
>>     goto label;
>> 
>> If a compiler can't optimize this, I reserve the right to refuse 
>> to trust it's optimizations on more complex constructs.

>Let us take your example. In the structured form of a loop, a compiler
>can specifically check for expressions that are constants and pull
>them out of the loop. In the second form, it has to first check that
>no other statement branches to the label from anywhere (in which case
>it may or may not be expressible as a simple while loop), and only
>then make the determination of what are constants. In fact, loop
>optimizations are usually easier than control flow analyses that
>you need to optimize the latter.

I don't agree.  Usually the optimization is done near the back-end
of the compiler, at which point both program segments will have
been decomposed into (identical) basic blocks anyway.  The compiler
then runs data flow analysis on them to find loop invariant expressions
and strength reductions etc. -- and will perform identically on
both examples.  Only a compiler with a weak optimizer may have to
rely on the actual while() statement used to enable certain optimizations.

Frank
--
The famous GIICM now on line:  http://www.xs4all.nl/~falstaff/GIICM.html
------------------------------------------------------------------------
Frank A. Vorstenbosch        +31-(70)-355 5241        falstaff@xs4all.nl
Technical Details
Message-ID: <4jbcjd$2l4@solutions.solon.com>
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
References: <4hqedf$1m0@solutions.solon.com> <4i2k0n$8jd@solutions.solon.com> <4i97ht$8gb@solutions.solon.com> <4ianbt$h8m@solutions.solon.com> <4ja3tl$pd6@solutions.solon.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
From: falstaff@xs4all.nl (Falstaff)
Newsgroups: comp.lang.c.moderated
Subject: Re: use of the break statement
Date: 27 Mar 1996 06:33:49 -0600
Organization: XS4ALL, networking for the masses
Sender: clc@solutions.solon.com
Approved: clc@solutions.solon.com
Message-ID: <4jbcjd$2l4@solutions.solon.com>
References: <4hqedf$1m0@solutions.solon.com> <4i2k0n$8jd@solutions.solon.com>  <4i97ht$8gb@solutions.solon.com> <4ianbt$h8m@solutions.solon.com> <4ja3tl$pd6@solutions.solon.com>
NNTP-Posting-Host: solutions.solon.com
X-Newsreader: NN version 6.5.0 #666 (NOV)