http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57275

            Bug ID: 57275
           Summary: Error in data dependence analysis during gather
                    vectorization
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: andrey.turetskiy at gmail dot com
                CC: kirill.yukhin at intel dot com

Created attachment 30110
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30110&action=edit
Test showing the error

I've tried to compile this code for AVX2 with different optimization options:

 #include <stdio.h>
 #define N 1024

 float a[N], b[N], c[N];
 int k[N];

 __attribute__((noinline, noclone)) void
 f (void)
 {
   int i;
   for (i = 0; i < N; i++)
     {
       a[i] = b[k[i]];
       b[i] = c[i];
     }
 }

 int main ()
 {
   int i;

   for (i = 0; i < N; i++)
     {
       k[i] = i%2;
       b[i] = i;
       c[i] = 179;
     }

   f ();

   if (a[2] != 179 || a[3] != 179)
     printf("TEST FAILED\n\n");
   else
     printf("TEST PASSED\n\n");

   return 0;
 }

Results are different:

# ./gcc -mavx2 -O2 gather_test.c -o qqq.exe
# sde -- ./qqq.exe
TEST PASSED

# ./gcc -mavx2 -O3 gather_test.c -o www.exe
# sde -- ./www.exe
TEST FAILED

This bug have appeared because of error in data dependence analysis for
gathers. The loop in function f() has interleaving memory access, so it mustn't
be vectorized.
Before 4.9.0 it works correctly.

Reply via email to