Imported Upstream version 4.7.3
[platform/upstream/gcc48.git] / gcc / testsuite / gcc.dg / vect / slp-reduc-3.c
1 /* { dg-require-effective-target vect_int } */
2
3 #include <stdarg.h>
4 #include "tree-vect.h"
5
6 #define N 64
7
8 #define DOT1 21834 
9 #define DOT2 21876
10
11 unsigned short X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
12 unsigned short Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
13
14 /* short->short->int dot product. 
15    Not detected as a dot-product pattern.
16    Requires support for non-widneing multiplication and widening-summation.  
17    Vectorized with loop-aware SLP. */
18 __attribute__ ((noinline)) unsigned int
19 foo1(int len, int *result1, int *result2) 
20 {
21   int i;
22   unsigned int res1 = 10, res2 = 20;
23   unsigned short prod;
24
25   for (i=0; i<len; i++) {
26     prod = X[2*i] * Y[2*i];
27     res1 += prod;
28     prod = X[2*i+1] * Y[2*i+1];
29     res2 += prod;
30   }
31
32   *result1 = res1;
33   *result2 = res2;
34
35   return 0;
36 }
37
38 int main (void)
39 {
40   unsigned int dot1, dot2;
41   unsigned short i;
42
43   check_vect ();
44
45   for (i=0; i<N; i++) {
46     X[i] = i;
47     Y[i] = 64-i;
48   }
49
50   foo1 (N/2, &dot1, &dot2);
51
52   if (dot1 != DOT1 || dot2 != DOT2)
53     abort ();
54
55   return 0;
56 }
57
58 /* The initialization loop in main also gets vectorized.  */
59 /* { dg-final { scan-tree-dump-times "vect_recog_dot_prod_pattern: detected" 1 "vect" { xfail *-*-* } } } */
60 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { target { vect_short_mult && { vect_widen_sum_hi_to_si  && vect_unpack } } } } } */ 
61 /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { xfail { vect_widen_sum_hi_to_si_pattern ||  { ! vect_unpack } } } } } */
62 /* { dg-final { cleanup-tree-dump "vect" } } */