(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
vect/
vect-widen-mult-1.c
       1  /* { dg-require-effective-target vect_int } */
       2  
       3  #include "tree-vect.h"
       4  
       5  #define N 50
       6  
       7  #ifndef SIGNEDNESS_1
       8  #define SIGNEDNESS_1 unsigned
       9  #define SIGNEDNESS_2 signed
      10  #endif
      11  
      12  void __attribute__ ((noipa))
      13  f (SIGNEDNESS_1 short *restrict a, SIGNEDNESS_2 char *restrict b,
      14     SIGNEDNESS_2 char *restrict c)
      15  {
      16    for (__INTPTR_TYPE__ i = 0; i < N; ++i)
      17      {
      18        int bv = (SIGNEDNESS_2 char) b[i];
      19        int cv = (SIGNEDNESS_2 char) c[i];
      20        a[i] = bv * cv;
      21      }
      22  }
      23  
      24  #define BASE ((SIGNEDNESS_2 int) -1 < 0 ? -126 : 4)
      25  #define OFFSET 20
      26  
      27  int
      28  main (void)
      29  {
      30    check_vect ();
      31  
      32    SIGNEDNESS_1 short a[N];
      33    SIGNEDNESS_2 char b[N], c[N];
      34    for (int i = 0; i < N; ++i)
      35      {
      36        b[i] = BASE + i * 5;
      37        c[i] = BASE + OFFSET + i * 4;
      38        asm volatile ("" ::: "memory");
      39      }
      40    f (a, b, c);
      41    for (int i = 0; i < N; ++i)
      42      if (a[i] != (SIGNEDNESS_1 short) ((BASE + i * 5)
      43  				      * (BASE + OFFSET + i * 4)))
      44        __builtin_abort ();
      45  }
      46  
      47  /* { dg-final { scan-tree-dump "vect_recog_widen_mult_pattern: detected" "vect" } } */
      48  /* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_widen_mult_qi_to_hi } } } */