Imported Upstream version 4.7.3
[platform/upstream/gcc48.git] / gcc / testsuite / gcc.dg / vect / vect-widen-mult-const-u16.c
1 /* { dg-require-effective-target vect_int } */
2
3 #include "tree-vect.h"
4 #include <stdlib.h>
5
6 #define N 32
7
8 __attribute__ ((noinline)) void 
9 foo (unsigned int *__restrict a,
10      unsigned short *__restrict b,
11      int n)
12 {
13   int i;
14
15   for (i = 0; i < n; i++)
16     a[i] = b[i] * 2333;
17
18   for (i = 0; i < n; i++)
19     if (a[i] != b[i] * 2333)
20       abort ();
21 }
22
23 __attribute__ ((noinline)) void
24 bar (unsigned int *__restrict a,
25      unsigned short *__restrict b,
26      int n)
27 {
28   int i;
29
30   for (i = 0; i < n; i++)
31     a[i] = (unsigned short) 2333 * b[i];
32
33   for (i = 0; i < n; i++)
34     if (a[i] != b[i] * (unsigned short) 2333)
35       abort ();
36 }
37
38 __attribute__ ((noinline)) void
39 baz (unsigned int *__restrict a,
40      unsigned short *__restrict b,
41      int n)
42 {
43   int i;
44
45   for (i = 0; i < n; i++)
46     a[i] = b[i] * 233333333;
47
48   for (i = 0; i < n; i++)
49     if (a[i] != b[i] * 233333333)
50       abort ();
51 }
52
53
54 int main (void)
55 {
56   int i;
57   unsigned int a[N];
58   unsigned short b[N];
59
60   for (i = 0; i < N; i++)
61     {
62       a[i] = 0;
63       b[i] = i;
64       __asm__ volatile ("");
65     }
66
67   foo (a, b, N);
68   bar (a, b, N);
69   baz (a, b, N);
70   return 0;
71 }
72
73 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 3 "vect" { target vect_widen_mult_hi_to_si } } } */
74 /* { dg-final { scan-tree-dump-times "vect_recog_widen_mult_pattern: detected" 2 "vect" { target vect_widen_mult_hi_to_si_pattern } } } */
75 /* { dg-final { scan-tree-dump-times "pattern recognized" 2 "vect" { target vect_widen_mult_hi_to_si_pattern } } } */
76 /* { dg-final { cleanup-tree-dump "vect" } } */
77