while loop code generation

ast@halcyon.com (Andrew Tucker)
14 Dec 1997 22:36:44 -0500

          From comp.compilers

Related articles
while loop code generation ast@halcyon.com (1997-12-14)
Re: while loop code generation gclind01@spd.louisville.edu (1997-12-15)
Re: while loop code generation burley@cygnus.com (Craig Burley) (1997-12-15)
Re: while loop code generation tgl@netcom.com (Tom Lane) (1997-12-15)
Re: while loop code generation n8tm@aol.com (1997-12-15)
Re: while loop code generation tim@franck.Princeton.EDU.composers (1997-12-29)
Re: while loop code generation preston@tera.tera.com (1998-01-03)
| List of all articles for this month |

From: ast@halcyon.com (Andrew Tucker)
Newsgroups: comp.compilers
Date: 14 Dec 1997 22:36:44 -0500
Organization: Northwest Nexus, Inc.
Keywords: code, question

On page 227 of Fraser and Hanson's _A Retargetable C Compiler_,
they claim that the code


goto L+1
L: statement
L+1: if expression != 0 goto L
L+2:


generates n+2 goto's for a loop executing statement n times while
the code


L:
L+1: if expression == 0 goto L+2
statement
goto L
L+2:


generates 2n+1 goto's.


Maybe my analysis (and my test code) are severely flawed, but
I see both layouts as equivalent, with n+1 gotos executed when
statement is executed n times.


Am I missing something or is their claim incorrect?




--
--
/* Andrew */
WWW: http://www.halcyon.com/ast
Email: ast@halcyon.com
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.