[PATCH] D23509: [LoopVectorize] Query TTI when deciding to splat IV

Michael Kuperstein via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 22 18:18:44 PDT 2016


mkuper added a comment.

In https://reviews.llvm.org/D23509#522258, @mssimpso wrote:

> Of course, the problem with this is that we actually still are vectorizing the uniform users of the IVs, creating uses of the vector IVs that we later can't remove. We shouldn't be doing this. I think the right fix is to have something like the following in each case in vectorizeBlockInLoop (except for PHIs and branches):
>
>   if (Legal->isScalarAfterVectorization(&I)) {
>     scalarizeInstruction(&I);
>     continue;
>   }
>
>
> If we've already decided that an instruciton should remain scalar, we shouldn't vectorize it. Does this make sense?


It's pretty odd that we don't already do this.
I assume the reason we don't already get a lot of garbage is because we have LICM before LV?

In https://reviews.llvm.org/D23509#522266, @anemet wrote:

> Can we please also have this loop explained at a higher level?  The IR in the testcase is not really digestible.


I can reproduce this with something like:

  void foo(int *p, int *q, short k) {
    for (short i = 0; i < 256; ++i)
      p[i + k] = q[i + k - 1] * 5 + 1;
  }

If we only have, say, "i + k" as the IV user, instcombine can clean this up, but it seems like it can't handle more complex cases. Haven't dug into why.


https://reviews.llvm.org/D23509





More information about the llvm-commits mailing list