(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
vect/
vect-tail-nomask-1.c
       1  /* { dg-skip-if "No undefined weak" { ! { posix_memalign } } } */
       2  /* { dg-additional-options "--param vect-epilogues-nomask=1 -mavx2" { target avx2_runtime } } */
       3  
       4  #define SIZE 1023
       5  #define ALIGN 64
       6  
       7  extern int posix_memalign(void **memptr, __SIZE_TYPE__ alignment, __SIZE_TYPE__ size);
       8  extern void free (void *);
       9  
      10  void __attribute__((noinline))
      11  test_citer (int * __restrict__ a,
      12  	    int * __restrict__ b,
      13  	    int * __restrict__ c)
      14  {
      15    int i;
      16  
      17    a = (int *)__builtin_assume_aligned (a, ALIGN);
      18    b = (int *)__builtin_assume_aligned (b, ALIGN);
      19    c = (int *)__builtin_assume_aligned (c, ALIGN);
      20  
      21    for (i = 0; i < SIZE; i++)
      22      c[i] = a[i] + b[i];
      23  }
      24  
      25  void __attribute__((noinline))
      26  test_viter (int * __restrict__ a,
      27  	    int * __restrict__ b,
      28  	    int * __restrict__ c,
      29  	    int size)
      30  {
      31    int i;
      32  
      33    a = (int *)__builtin_assume_aligned (a, ALIGN);
      34    b = (int *)__builtin_assume_aligned (b, ALIGN);
      35    c = (int *)__builtin_assume_aligned (c, ALIGN);
      36  
      37    for (i = 0; i < size; i++)
      38      c[i] = a[i] + b[i];
      39  }
      40  
      41  void __attribute__((noinline))
      42  init_data (int * __restrict__ a,
      43  	   int * __restrict__ b,
      44  	   int * __restrict__ c,
      45  	   int size)
      46  {
      47    for (int i = 0; i < size; i++)
      48      {
      49        a[i] = i;
      50        b[i] = -i;
      51        c[i] = 0;
      52        asm volatile("": : :"memory");
      53      }
      54    a[size] = b[size] = c[size] = size;
      55  }
      56  
      57  
      58  void __attribute__((noinline))
      59  run_test ()
      60  {
      61    int *a;
      62    int *b;
      63    int *c;
      64    int i;
      65  
      66    if (posix_memalign ((void **)&a, ALIGN, (SIZE + 1) * sizeof (int)) != 0)
      67      return;
      68    if (posix_memalign ((void **)&b, ALIGN, (SIZE + 1) * sizeof (int)) != 0)
      69      return;
      70    if (posix_memalign ((void **)&c, ALIGN, (SIZE + 1) * sizeof (int)) != 0)
      71      return;
      72  
      73    init_data (a, b, c, SIZE);
      74    test_citer (a, b, c);
      75    for (i = 0; i < SIZE; i++)
      76      if (c[i] != a[i] + b[i])
      77        __builtin_abort ();
      78    if (a[SIZE] != SIZE || b[SIZE] != SIZE || c[SIZE] != SIZE)
      79      __builtin_abort ();
      80  
      81    init_data (a, b, c, SIZE);
      82    test_viter (a, b, c, SIZE);
      83    for (i = 0; i < SIZE; i++)
      84      if (c[i] != a[i] + b[i])
      85        __builtin_abort ();
      86    if (a[SIZE] != SIZE || b[SIZE] != SIZE || c[SIZE] != SIZE)
      87      __builtin_abort ();
      88  
      89    free (a);
      90    free (b);
      91    free (c);
      92  }
      93  
      94  int
      95  main (int argc, const char **argv)
      96  {
      97    run_test ();
      98    return 0;
      99  }
     100  
     101  /* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 2 "vect" { target avx2_runtime } } } */
     102  /* { dg-final { scan-tree-dump-times "LOOP EPILOGUE VECTORIZED \\(MODE=V16QI\\)" 2 "vect" { target avx2_runtime } } } */