[PATCH] [Commented On] D24796: [SLPVectorizer] Fix for PR25748: reduction vectorization after loop unrolling.

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 29 23:58:50 PDT 2016


ABataev added inline comments.


> mkuper wrote in SLPVectorizer.cpp:1797
> Why do you need this change?

It is required to handle the next kind of hor reduction:

  sum = a + b + c + ...

It comes from:

  int test(unsigned int *p) {
    int sum = 0;
    for (int i = 0; i < 8; i++)
      sum += p[i];
    return sum;
  }

> mkuper wrote in SLPVectorizer.cpp:4171
> This comment looks wrong now. Could you replace it with a comment that explains the current situation?

Ok, will do it

> mkuper wrote in SLPVectorizer.cpp:4586
> I actually started coding a similar patch at some point, but decided against it, because the "return" here seems really fairly accidental.
> You could just as easily have something like:
> 
>   int test(unsigned int *p) {
>     int sum = 0;
>     for (int i = 0; i < 8; i++)
>       sum += p[i];
>     return sum + 5;
>   }
> 
> It may be the case that having it feed a return is an important special case, but maybe we can work out a full solution for this.

Michael,
I'm working on a general patch, that is able to vectorize your example (I have it already but need some time to improve it). But this patch is still required as a first step for the second patch. Later we can rework this code for better compatibility

https://reviews.llvm.org/D24796





More information about the llvm-commits mailing list