(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
vect/
vect-92.c
       1  /* Disabling epilogues until we find a better way to deal with scans.  */
       2  /* { dg-additional-options "--param vect-epilogues-nomask=0" } */
       3  /* { dg-require-effective-target vect_float } */
       4  
       5  #include <stdarg.h>
       6  #include "tree-vect.h"
       7  
       8  #define N 256
       9  
      10  float pa[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
      11  float pb[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57};
      12  float pc[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
      13  
      14  /* Check handling of unaligned accesses when the misalignment is
      15     known at compile time and different accesses have the same
      16     misalignment (e.g. peeling to align one access will align all
      17     accesses with the same misalignment.  Also, the number of 
      18     peeled iterations is known in this case, and the vectorizer
      19     can use this information (generate prolog and epilog loops
      20     with known number of iterations, and only if needed).  */
      21  
      22  #if VECTOR_BITS > 128
      23  #define NITER (VECTOR_BITS * 3 / 32)
      24  #else
      25  #define NITER 12
      26  #endif
      27  
      28  __attribute__ ((noinline)) int
      29  main1 ()
      30  {
      31    int i;
      32  
      33    for (i = 0; i < NITER - 2; i++)
      34      {
      35        pa[i+1] = pb[i+1] * pc[i+1];
      36      }
      37  
      38    /* check results:  */
      39    for (i = 0; i < 10; i++)
      40      {
      41        if (pa[i+1] != (pb[i+1] * pc[i+1]))
      42  	abort ();
      43      }
      44  
      45    return 0;
      46  }
      47  
      48  __attribute__ ((noinline)) int
      49  main2 ()
      50  {
      51    int i;
      52  
      53    for (i = 0; i < NITER; i++)
      54      {
      55        pa[i+1] = pb[i+1] * pc[i+1];
      56      }
      57  
      58    /* check results:  */
      59    for (i = 0; i < 12; i++)
      60      {
      61        if (pa[i+1] != (pb[i+1] * pc[i+1]))
      62  	abort ();
      63      }
      64  
      65    return 0;
      66  }
      67  
      68  __attribute__ ((noinline)) int
      69  main3 (int n)
      70  {
      71    int i;
      72  
      73    for (i = 0; i < n; i++)
      74      {
      75        pa[i+1] = pb[i+1] * pc[i+1];
      76      }
      77  
      78    /* check results:  */
      79    for (i = 0; i < n; i++)
      80      {
      81        if (pa[i+1] != (pb[i+1] * pc[i+1]))
      82  	abort ();
      83      }
      84  
      85    return 0;
      86  }
      87  
      88  int main (void)
      89  {
      90    int i;
      91  
      92    check_vect ();
      93  
      94    main1 ();
      95    main2 ();
      96    main3 (N-1);
      97  
      98    return 0;
      99  }
     100  
     101  /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 3 "vect" } } */
     102  /* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" } } */
     103  /* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 3 "vect" { xfail vect_element_align_preferred } } } */