Shoud a subset loop with same header be inner ?

viren@wipro.wipsys.soft.net (Virendra Kumar Mehta)
Thu, 20 Jan 1994 08:45:01 GMT

          From comp.compilers

Related articles
Shoud a subset loop with same header be inner ? viren@wipro.wipsys.soft.net (1994-01-20)
Re: Shoud a subset loop with same header be inner? vick@wotangate.sc.ti.com (1994-01-21)
Re: Shoud a subset loop with same header be inner ? steven.parker@acadiau.ca (1994-01-21)
Re: Shoud a subset loop with same header be inner ? cliffc@dawn.cs.rice.edu (1994-01-23)
| List of all articles for this month |
Newsgroups: comp.compilers
From: viren@wipro.wipsys.soft.net (Virendra Kumar Mehta)
Keywords: optimize, question
Organization: Compilers Central
Date: Thu, 20 Jan 1994 08:45:01 GMT

Hi all!


The new dragon book talks about merging loops with the same header if they
are not proper subsets of each other as in


(1)
                                                ___
                        ---------->/ \<----------
                        | \___/ |
                        | | |
                        | | |
                        | _v_ |
                        | / \ (2) |
                        | \___/ |
                        | / \ |
                        | / \ |
                        | | | |
                        | _v_ _v_ |
                          \____/ \ / \____/
                                    \___/ \___/
(3) (4)


The two loops {1, 2, 3} and {1, 2, 4} are merged together as none is a
inner loop of another. It also talks about loops which are proper subsets
of others, which can be conveniently treated as inner loops. It doesn't
however talk of a loop which is a subset of another, and also shares the
same header as in


(1)
                                                ___
                        ---------->/ \<----------
                        | \___/ |
                        | | |
                        | | |
                        | _v_ |
                        \__________/ \ (2) |
                                              \___/ |
                                                  | |
                                                  | |
                                                _v_ |
                                      (3) / \_________/
                                              \___/


This situation will arise, e.g. if there is a 'continue' in a while loop.
My question is, should the loop {1, 2} be treated as an inner loop, nested
in the outer loop {1, 2, 3} or should the two loops be treated as same?
What are the advantages/disadvantages of the two schemes and what kind of
optimizations are affected ?


I doubt if treating {1, 2} as an inner loop will serve much purpose, as we
can't assume that it will execute a higher number of times than the outer
loop.


Regards.
  --
Virendra Kr Mehta, e-mail: viren@wipro.wipsys.soft.net
--


Post a followup to this message

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