(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
vect/
vect-93.c
       1  /* { dg-require-effective-target vect_float } */
       2  /* { dg-additional-options "--param vect-max-peeling-for-alignment=0" } */
       3  
       4  #include <stdarg.h>
       5  #include "tree-vect.h"
       6  
       7  #define N1 3001
       8  
       9  #if VECTOR_BITS > 256
      10  #define N2 (VECTOR_BITS / 32 + 2)
      11  #else
      12  #define N2 10
      13  #endif
      14  
      15  __attribute__ ((noinline)) int
      16  main1 (float *pa)
      17  {
      18    int i;
      19  
      20    for (i = 0; i < N1; i++)
      21      {
      22        pa[i] = 2.0;
      23      }
      24  
      25    /* check results:  */
      26    for (i = 0; i < N1; i++)
      27      {
      28        if (pa[i] != 2.0)
      29  	abort ();
      30      }
      31  
      32  #pragma GCC unroll 0
      33    for (i = 1; i <= N2; i++)
      34      {
      35        pa[i] = 3.0;
      36      }
      37  
      38    /* check results:  */
      39    for (i = 1; i <= N2; i++)
      40      {
      41        if (pa[i] != 3.0)
      42  	abort ();
      43      }
      44    
      45    return 0;
      46  }
      47  
      48  int main (void)
      49  {
      50    int i;
      51    float a[N1] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
      52    float b[N1] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
      53  
      54    check_vect ();
      55  
      56    /* from bzip2: */
      57    for (i = 0; i < N1; i++)
      58      b[i] = i;
      59    a[0] = 0;
      60    for (i = 1; i <= 256; i++) a[i] = b[i-1];
      61  
      62    /* check results:  */
      63    for (i = 1; i <= 256; i++)
      64      {
      65        if (a[i] != i-1)
      66  	abort ();
      67      }
      68    if (a[0] != 0)
      69      abort ();
      70  
      71    main1 (a);
      72  
      73    return 0;
      74  }
      75  
      76  /* 2 loops vectorized in main1, 2 loops vectorized in main:
      77     the first loop in main requires vectorization of conversions,
      78     the second loop in main requires vectorization of misaligned load.  */
      79  
      80  /* main && main1 together: */
      81  /* { dg-final { scan-tree-dump-times "vectorized 2 loops" 2 "vect" { target powerpc*-*-* i?86-*-* x86_64-*-* } } } */
      82  
      83  /* in main1: */
      84  /* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" { target !powerpc*-*-* !i?86-*-* !x86_64-*-* } } } */
      85  /* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" { target { vect_no_align && { ! vect_hw_misalign } } } } } */
      86  
      87  /* in main: */
      88  /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_no_align && { ! vect_hw_misalign } } } } } */
      89