[PATCH/RFC] Pre-increment preparation pass

Andrew Trick atrick at apple.com
Tue Feb 5 21:20:23 PST 2013


On Feb 5, 2013, at 8:52 PM, Hal Finkel <hfinkel at anl.gov> wrote:

>> Currently, the head of the chain is still considered an IVUser by
>> LSR's solver and will be rewritten. The easy thing might be to add
>> it to IVIncSet so LSR totally ignores it, then directly generate a
>> phi later that would only be used by that chain. The more
>> sophisticated approach would be to force LSR's formulae to use a
>> register holding the expression for the phi that we intend to
>> create. If you do that, LSR's rewriter might then generate the phi.
>> GenerateIVChain could to recognize the phi that has a matching
>> expression, but rewrite the back edge to use the result of the last
>> instruction in the chain.
> 
> It sounds like the "sophisticated approach" is the right one, do you agree?

Yes. I don't know how easy it will be.

>>>> High level question: does LSR actually benefit your target? One
>>>> option is to have a target hooks that bypasses the LSR solver but
>>>> allows IV chains to be formed.
>>> 
>>> I've not experimented with turning it off. PPC does not have scaled
>>> addressing modes, so it does not benefit from that part of it, but
>>> it may at least benefit from the simplifications of the exit
>>> condition (if not other things).
>> 
>> It's partly a question of whether you tend to run out of registers on
>> unrolled loops.
> 
> No, spilling is very expensive on the BG/Q. That having been said, getting good performance often means covering a lot of latency, and that often requires running close to the register limit. As a result, we might go over sometimes. Also, scientific codes sometimes have manually-unrolled loops, and I'd like to compile those well.

Then it depends on whether the person manually unrolling the loops has knowledge of the micro architecture. I so, disable LSR. If not, then the situation you describe is a good fit for LSR. Except that the original algorithm didn't do well on unrolled loops. IVChains are meant to help with that. It can hide the unrolled iterations from the LSR solver.

-Andy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130205/a62d6285/attachment.html>


More information about the llvm-commits mailing list