Re: spaghetti code

preston@dawn.cs.rice.edu (Preston Briggs)
Mon, 2 Mar 1992 18:58:30 GMT

          From comp.compilers

Related articles
spaghetti code preston@dawn.cs.rice.edu (1992-02-22)
spaghetti code adegrey@active-book-co.co.uk (1992-02-28)
Re: spaghetti code preston@dawn.cs.rice.edu (1992-03-02)
| List of all articles for this month |

Newsgroups: comp.compilers
From: preston@dawn.cs.rice.edu (Preston Briggs)
Keywords: optimize, analysis
Organization: Rice University, Houston
References: 92-03-005
Date: Mon, 2 Mar 1992 18:58:30 GMT

adegrey@active-book-co.co.uk (Aubrey de Grey) writes:


>but as far as I can see the problem of optimising spaghetti
>code as opposed to structured code is one of turning each procedure into a
>form where no pair of jumps (forward or backward) is linked. (A pair of
>jumps is linked when each jump encloses exactly one end of the other.)


No. "Linked loops" are no problem. They're just nested in a perhaps
non-intuitive fashion. The optimizer has no problem with them.
The only "problem" is irreducible loops (loops with more than one
entry) and they aren't that bad a problem since node-splitting can
always be applied.


>statement1; <-------
>label1; |
>statement2; <---- |
>label2; | |
>statement3; | |
>if condition1 then goto label1; >------
>statement4; |
>if condition2 then goto label2; >---
>statement5;


In this case, there's just a loop nest with 2 loops.
The outer nest includes statements 2, 3, and 4.
The inner loop includes statements 3 and 4.


Preston Briggs
--


Post a followup to this message

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