This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [tree-ssa] Dce & infinite loops
- From: Richard Guenther <rguenth at tat dot physik dot uni-tuebingen dot de>
- To: Diego Novillo <dnovillo at redhat dot com>
- Cc: Steven Bosscher <stevenb at suse dot de>,Zdenek Dvorak <rakdver at atrey dot karlin dot mff dot cuni dot cz>, gcc at gcc dot gnu dot org
- Date: Thu, 18 Mar 2004 15:43:46 +0100 (CET)
- Subject: Re: [tree-ssa] Dce & infinite loops
On Thu, 2004-03-18 at 07:31, Steven Bosscher wrote:
> Removing an infinte loop is indeed wrong. Hence this comment
> in tree-ssa-dce.c:
>
> /* Some blocks don't have an immediate post dominator. This can
happen
> for example with infinite loops. Removing an infinite loop is an
> inappropriate transformation anyway... */
>
> If we remove that infinite loop, you found a bug.
>
Diego wrote:
> I've always hated this custom. Is this a language mandate? Or just
> "we've always done it this way"? Why not tell the user to use a
> volatile index variable if they want the infinite loop?
People - you may never remove infinite loops because that would change
program behavior for f.i.:
int main() {
printf("1");
for (;;) ;
printf("1");
return 0;
}
The "best" (or worst to someone for sure) would be, if the C standard says
infinite loops result in undefined behavior (as program never terminates),
to reject the program. But never silently delete them.
For optimizing away empty (but finite) loops, this is certainly correct,
though maybe not what Joe average kernel hacker would expect ;) I.e.
issuing a warning if doing that is highly appreciated.
Richard.
--
Richard Guenther <richard dot guenther at uni-tuebingen dot de>
WWW: http://www.tat.physik.uni-tuebingen.de/~rguenth/