Re: Backward branches (Torben Ęgidius Mogensen)
20 Dec 2003 11:44:36 -0500

          From comp.compilers

Related articles
Backward branches (2003-12-14)
Re: Backward branches (2003-12-20)
Re: Backward branches (2003-12-21)
Re: Backward branches (2004-01-02)
Re: Backward branches (2004-01-09)
Re: Backward branches (Jens Troeger) (2004-01-12)
Re: Backward branches (Robert Thorpe) (2004-01-16)
| List of all articles for this month |

From: (Torben Ęgidius Mogensen)
Newsgroups: comp.compilers
Date: 20 Dec 2003 11:44:36 -0500
Organization: Department of Computer Science, University of Copenhagen
References: 03-12-108
Keywords: optimize, architecture
Posted-Date: 20 Dec 2003 11:44:36 EST (kugan) writes:

> I need to detect loops using H/W. I am wondering whether it is
> possible to detect loops just by detecting backward branches. What
> would be the approximate success rate for this scheme? What are the
> other instances where backward branches will be used?

Any loop (that hasn't been fully unrolled) will certainly involve a
backwards branch at some point. Not all backwards branches are loops,
though. If you reorder basic blocks, you can well have one branch of
an if-then-else placed after the join-point, so you need a backwards
jump to get to the join-point. Jumps to exception-handling code can
also be backwards, but compilers would tend to make these forwards as
some branch predictors assume backwards branches are taken (until they
have gathered evidence to the contrary).

In summary: All lopps involve backwards branches. It is possible for
a compiler to arrange that all backwards branches are loops, but you
shouldn't bet on it.


Post a followup to this message

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