Re: Backward branches

torbenm@diku.dk (Torben Ęgidius Mogensen)
20 Dec 2003 11:44:36 -0500

          From comp.compilers

Related articles
Backward branches kugan@ieee.org (2003-12-14)
Re: Backward branches torbenm@diku.dk (2003-12-20)
Re: Backward branches haberg@matematik.su.se (2003-12-21)
Re: Backward branches kugan@ieee.org (2004-01-02)
Re: Backward branches vbdis@aol.com (2004-01-09)
Re: Backward branches j.troeger@qut.edu.au (Jens Troeger) (2004-01-12)
Re: Backward branches Robert.Thorpe@antenova.com (Robert Thorpe) (2004-01-16)
| List of all articles for this month |
From: torbenm@diku.dk (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@ieee.org (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.


Torben


Post a followup to this message

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