(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
vect/
bb-slp-over-widen-1.c
       1  /* { dg-require-effective-target vect_int } */
       2  /* { dg-require-effective-target vect_shift } */
       3  /* { dg-require-effective-target vect_pack_trunc } */
       4  /* { dg-require-effective-target vect_unpack } */
       5  
       6  #include "tree-vect.h"
       7  
       8  /* Deliberate use of signed >>.  */
       9  #define DEF_LOOP(SIGNEDNESS)			\
      10    void __attribute__ ((noipa))			\
      11    f_##SIGNEDNESS (SIGNEDNESS char *restrict a,	\
      12  		  SIGNEDNESS char *restrict b,	\
      13  		  SIGNEDNESS char *restrict c)	\
      14    {						\
      15      a[0] = (b[0] + c[0]) >> 1;			\
      16      a[1] = (b[1] + c[1]) >> 1;			\
      17      a[2] = (b[2] + c[2]) >> 1;			\
      18      a[3] = (b[3] + c[3]) >> 1;			\
      19      a[4] = (b[4] + c[4]) >> 1;			\
      20      a[5] = (b[5] + c[5]) >> 1;			\
      21      a[6] = (b[6] + c[6]) >> 1;			\
      22      a[7] = (b[7] + c[7]) >> 1;			\
      23      a[8] = (b[8] + c[8]) >> 1;			\
      24      a[9] = (b[9] + c[9]) >> 1;			\
      25      a[10] = (b[10] + c[10]) >> 1;		\
      26      a[11] = (b[11] + c[11]) >> 1;		\
      27      a[12] = (b[12] + c[12]) >> 1;		\
      28      a[13] = (b[13] + c[13]) >> 1;		\
      29      a[14] = (b[14] + c[14]) >> 1;		\
      30      a[15] = (b[15] + c[15]) >> 1;		\
      31    }
      32  
      33  DEF_LOOP (signed)
      34  DEF_LOOP (unsigned)
      35  
      36  #define N 16
      37  
      38  #define TEST_LOOP(SIGNEDNESS, BASE_B, BASE_C)		\
      39    {							\
      40      SIGNEDNESS char a[N], b[N], c[N];			\
      41      for (int i = 0; i < N; ++i)				\
      42        {							\
      43  	b[i] = BASE_B + i * 15;				\
      44  	c[i] = BASE_C + i * 14;				\
      45  	asm volatile ("" ::: "memory");			\
      46        }							\
      47      f_##SIGNEDNESS (a, b, c);				\
      48      for (int i = 0; i < N; ++i)				\
      49        if (a[i] != (BASE_B + BASE_C + i * 29) >> 1)	\
      50  	__builtin_abort ();				\
      51    }
      52  
      53  int
      54  main (void)
      55  {
      56    check_vect ();
      57  
      58    TEST_LOOP (signed, -128, -120);
      59    TEST_LOOP (unsigned, 4, 10);
      60  
      61    return 0;
      62  }
      63  
      64  /* { dg-final { scan-tree-dump "demoting int to signed short" "slp2" { target { ! vect_widen_shift } } } } */
      65  /* { dg-final { scan-tree-dump "demoting int to unsigned short" "slp2" { target { ! vect_widen_shift } } } } */
      66  /* { dg-final { scan-tree-dump {\.AVG_FLOOR} "slp2" { target vect_avg_qi } } } */
      67  /* { dg-final { scan-tree-dump-times "optimized: basic block" 2 "slp2" { target vect_hw_misalign } } } */