[PATCH] D102748: [LoopUnroll] Don't unroll before vectorisation

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 19 02:46:15 PDT 2021


fhahn added a comment.

In D102748#2767983 <https://reviews.llvm.org/D102748#2767983>, @SjoerdMeijer wrote:

> I believe unrolling before vectorisation is fundamentally the wrong approach.

It is indeed suboptimal for a subset of loops which can be vectorized by LV and the SLP.

But in a lot other cases, early unrolling enables other passes to perform many additional simplifications as @nikic mentioned and I think it is very easy to come up with examples to show that, because a lot of simplification passes don't work well on loops. Just one example below. With early unrolling, LLVM will eliminate the memset, without early unrolling it won't. I would expect simplifications due to early unrolling to be quite helpful for a lot of general non-benchmark code with few vectorizable loops.

  void foo(char *Ptr) {
      memset(Ptr, 0, 16);
  
      for (unsigned i = 0; i < 16; i++ )
        Ptr[i] = i+1;
  }



> This, I think, also relies on the loop vectoriser which seems more powerful than SLP vectorisation currently

One major difference is that LV can use runtime checks to ensure memory access do not alias. I suspect that's the main issue blocking SLP in the case in the description.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102748/new/

https://reviews.llvm.org/D102748



More information about the llvm-commits mailing list