[PATCH] D50474: [LV] Vectorize header phis that feed from if-convertable latch phis

Anna Thomas via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 9 15:05:27 PDT 2018


anna added a comment.

In https://reviews.llvm.org/D50474#1194394, @efriedma wrote:

> Your patch miscompiles the following:
>
>   void f(int n, int *p, int *z) {
>   int x = 100;
>   #pragma clang loop vectorize(enable)
>   for (int i = 0; i < n; ++i) {
>   if (p[i] > 0) x *= p[i];
>   else x /= p[i];
>   z[i]=x;
>   }
>   }
>   typedef void fty(int,int*,int*);
>   fty*volatile ff=f;
>   int main() {
>     int p[] = {1,-2,3,-4};
>     int z[] = {1,2,3,4};
>     ff(4, p, z);
>     printf("%d %d %d %d\n", z[0], z[1], z[2], z[3]);
>   }
>


yeah, that's right. The header phi is a predicated reduction and we'll miscompile with a splatted preheader value. 
I think it would be okay if the iteration dependence distance > VF.
However, the case I'm interested in is a "predicated reduction". The header phi is just not recognized as a reduction.


Repository:
  rL LLVM

https://reviews.llvm.org/D50474





More information about the llvm-commits mailing list