www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/09/18/09:07:24.4

From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: -O3 doesnt remove dead code
Date: 14 Sep 2002 17:34:17 GMT
Organization: Aachen University of Technology (RWTH)
Lines: 23
Message-ID: <alvrup$25r$1@nets3.rz.RWTH-Aachen.DE>
References: <Xns92899374FFC7raf256com AT 213 DOT 180 DOT 128 DOT 20>
NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de
X-Trace: nets3.rz.RWTH-Aachen.DE 1032024857 2235 137.226.32.75 (14 Sep 2002 17:34:17 GMT)
X-Complaints-To: abuse AT rwth-aachen DOT de
NNTP-Posting-Date: 14 Sep 2002 17:34:17 GMT
Originator: broeker@
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Rafal 'Raf256' Maj <rafal AT raf256 DOT com> wrote:
> Hello,
> Following program compield with -03 does NOT had dead-code loop removed. 
> This empty loop actualy IS executed (and program takes few seconds to 
> complete)

> int main() { for (long long int i=0; i<500000000; i++) ; return 0; } 

> IMHO compiler at -O3 should optimize code to :

> int main() { return 0; } 

> why this dead-loop is not removed ?

Because the GCC people explicitly decided to not do that, IIRC.  The
distinction being that a loop explicitly coded with an empty body is
probably a timing-critical delay loop, and as such should be left
alone.  If you put something into the loop, and try again, you just
might see what you expected.

-- 
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019