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

From: "Rafal 'Raf256' Maj" <rafal AT raf256 DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: -O3 doesnt remove dead code
Date: 14 Sep 2002 17:55:42 GMT
Organization: news.onet.pl
Lines: 30
Sender: raf256 AT poczta DOT onet DOT pl@rafal.joint.eu.org
Message-ID: <Xns9289C9FBD262Draf256com@213.180.128.20>
References: <Xns92899374FFC7raf256com AT 213 DOT 180 DOT 128 DOT 20> <alvrup$25r$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE>
NNTP-Posting-Host: rafal.joint.eu.org
Mime-Version: 1.0
X-Trace: news.onet.pl 1032026142 2338 62.233.182.179 (14 Sep 2002 17:55:42 GMT)
X-Complaints-To: abuse AT onet DOT pl
NNTP-Posting-Date: 14 Sep 2002 17:55:42 GMT
User-Agent: Xnews/5.03.24
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de> wrote in 
news:alvrup$25r$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE

>> int main() { for (long long int i=0; i<500000000; i++) ; 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.

int a;
for (long long int i=0; i<500000000; i++) a=0;

gives same result :-/

IMHO time-critical loops should be marked as :

for (volatile long long int i=0; i<500000000; i++) ;
     ^^^^^^^^
this will never be optimized. And all dead codes should be deleted (this 
loop is not due to volatile counter)

Meybe I should report somwhere that 'bug' ? I use gcc 2.95 


-- 
Rafał 'Raf256' Maj
http://www.raf256.com

- Raw text -


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