[LSR] Don't try and create post-inc expressions on non-rotated loops
authorJames Molloy <james.molloy@arm.com>
Mon, 15 Aug 2016 07:53:03 +0000 (07:53 +0000)
committerJames Molloy <james.molloy@arm.com>
Mon, 15 Aug 2016 07:53:03 +0000 (07:53 +0000)
commit196ad0823e67bffef39983fbd9d7c13fb25911b6
tree9bdc1e2cbd6c94f8f75a6304847c91a206b6b7fe
parenta5c8a685356a5c5e956723429f7c2c39f8fbcd37
[LSR] Don't try and create post-inc expressions on non-rotated loops

If a loop is not rotated (for example when optimizing for size), the latch is not the backedge. If we promote an expression to post-inc form, we not only increase register pressure and add a COPY for that IV expression but for all IVs!

Motivating testcase:

    void f(float *a, float *b, float *c, int n) {
      while (n-- > 0)
        *c++ = *a++ + *b++;
    }

It's imperative that the pointer increments be located in the latch block and not the header block; if not, we cannot use post-increment loads and stores and we have to keep both the post-inc and pre-inc values around until the end of the latch which bloats register usage.

llvm-svn: 278658
llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
llvm/test/CodeGen/AMDGPU/wqm.ll
llvm/test/CodeGen/ARM/2011-03-23-PeepholeBug.ll
llvm/test/CodeGen/Hexagon/hwloop-crit-edge.ll
llvm/test/CodeGen/Hexagon/hwloop-loop1.ll
llvm/test/CodeGen/X86/lsr-loop-exit-cond.ll
llvm/test/Transforms/LoopStrengthReduce/post-inc-optsize.ll [new file with mode: 0644]