[llvm] r179026 - Generate PPC early conditional returns

Hal Finkel hfinkel at anl.gov
Mon Apr 8 22:09:01 PDT 2013


----- Original Message -----
> From: "Chris Lattner" <clattner at apple.com>
> To: "Hal Finkel" <hfinkel at anl.gov>
> Cc: llvm-commits at cs.uiuc.edu
> Sent: Monday, April 8, 2013 8:04:17 PM
> Subject: Re: [llvm] r179026 - Generate PPC early conditional returns
> 
> 
> On Apr 8, 2013, at 9:24 AM, Hal Finkel <hfinkel at anl.gov> wrote:
> 
> > Author: hfinkel
> > Date: Mon Apr  8 11:24:03 2013
> > New Revision: 179026
> > 
> > URL: http://llvm.org/viewvc/llvm-project?rev=179026&view=rev
> > Log:
> > Generate PPC early conditional returns
> > 
> > PowerPC has a conditional branch to the link register (return)
> > instruction: BCLR.
> > This should be used any time when we'd otherwise have a conditional
> > branch to a
> > return. This adds a small pass, PPCEarlyReturn, which runs just
> > prior to the
> > branch selection pass (and, importantly, after block placement) to
> > generate
> > these conditional returns when possible. It will also eliminate
> > unconditional
> > branches to returns (these happen rarely; most of the time these
> > have already
> > been tail duplicated by the time PPCEarlyReturn is invoked). This
> > is a nice
> > optimization for small functions that do not maintain a stack
> > frame.
> 
> Hi Hal,
> 
> Should this just be a special case of general predication/if
> conversion?

It seems like it should be, but I'm not sure. The regular if conversion pass is generally added in addPreSched2, which is after epilogue generation, and so it could work. When I looked through the source to IfConversion.cpp, it did not seem like it would have supported this transformation. IfConversion seems to be looking for blocks to predicate in between the conditional branch and the common successor, and not specifically concerned with tail merging a predicated common successor into the common predecessor; something which may only make sense if the common sucessor is a return). This may really be more of a peephole-style optimization than a predication optimization. Evan?

 -Hal

> 
> -Chris
> 



More information about the llvm-commits mailing list