(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
vect/
vect-105.c
       1  /* { dg-require-effective-target vect_int } */
       2  
       3  #include <stdlib.h>
       4  #include <stdarg.h>
       5  #include "tree-vect.h"
       6  
       7  #define N 4
       8  
       9  struct extraction
      10  {
      11    int a[N][N];
      12    int b[N][N];
      13  };
      14  
      15  static int a[N][N] = {{1,2,3,11},{4,5,6,12},{7,8,9,13},{34,45,67,83}};
      16  static int b[N][N] = {{17,28,15,23},{0,2,3,24},{4,31,82,25},{29,31,432,256}};
      17  static int c[N][N] = {{1,2,3,11},{4,9,13,34},{45,67,83,13},{34,45,67,83}};
      18  
      19  __attribute__ ((noinline))
      20  int main1 (int x) {
      21    int i,j;
      22    struct extraction *p;
      23    p = (struct extraction *) malloc (sizeof (struct extraction));
      24  
      25    for (i = 0; i < N; i++)
      26     {
      27      for (j = 0; j < N; j++)
      28       {
      29         p->a[i][j] = a[i][j];
      30         p->b[i][j] = b[i][j];
      31         asm volatile ("" ::: "memory");
      32       }
      33     }
      34  
      35    /* Vectorizable: distance > number of iterations.  */
      36    for (i = 1; i < N; i++)
      37    {
      38  #pragma GCC unroll 0
      39      for (j = 0; j < N; j++)
      40      {
      41         *((int *)p + x + i + j) = *((int *)p + x + i + j + 5);
      42      }
      43    }
      44  
      45    /* check results: */
      46    for (i = 0; i < N; i++)
      47     {
      48      for (j = 0; j < N; j++)
      49       {
      50         if (p->a[i][j] != c[i][j])
      51           abort();
      52       }
      53    }
      54    return 0;
      55  }
      56  
      57  int main (void)
      58  { 
      59    check_vect ();
      60  
      61    return main1 (N);
      62  }
      63  
      64  /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
      65  /* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 2 "vect" { target { vect_no_align && { ! vect_hw_misalign } } } } } */
      66  /* { dg-final { scan-tree-dump-times "possible dependence between data-refs" 0 "vect" } } */
      67