summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/vect/vect-widen-mult-sum.c
blob: 2898918306c963bebcf19f03267e2e344cc40b7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* { dg-require-effective-target vect_int } */

#include <stdarg.h>
#include "tree-vect.h"

#define N 64
#define SUM 0 
 
/* Require widening-mult or data-unpacking (for the type promotion).  */
__attribute__ ((noinline)) int
main1 (short *in, int off, short scale, int n)
{
 int i;
 int sum = 0;

 for (i = 0; i < n; i++) {
   sum += ((int) in[i] * (int) in[i+off]) >> scale;
 }

 return sum;
}

int main (void)
{
  int i;
  int sum;
  short X[N];

  check_vect ();

  for (i=0; i<N; i++) {
    X[i] = 16-i; 
    __asm__ volatile ("");
  }

  sum = main1 (X, 1, 16, N-1);
  
  if (sum != SUM)
    abort ();

  return 0;
}


/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_widen_mult_hi_to_si } } } */
/* { dg-final { scan-tree-dump-times "vect_recog_widen_mult_pattern: detected" 1 "vect" } } */
/* { dg-final { cleanup-tree-dump "vect" } } */