Imported Upstream version 4.7.3
[platform/upstream/gcc48.git] / gcc / testsuite / gcc.dg / vect / vect-widen-mult-const-s16.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 (int *__restrict a,
10      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 (int *__restrict a,
25      short *__restrict b,
26      int n)
27 {
28   int i;
29
30   for (i = 0; i < n; i++)
31     a[i] = b[i] * (short) 2333;
32
33   for (i = 0; i < n; i++)
34     if (a[i] != b[i] * (short) 2333)
35       abort ();
36 }
37
38 int main (void)
39 {
40   int i;
41   int a[N];
42   short b[N];
43
44   for (i = 0; i < N; i++)
45     {
46       a[i] = 0;
47       b[i] = i;
48       __asm__ volatile ("");
49     }
50
51   foo (a, b, N);
52   bar (a, b, N);
53   return 0;
54 }
55
56 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { target vect_widen_mult_hi_to_si } } } */
57 /* { dg-final { scan-tree-dump-times "vect_recog_widen_mult_pattern: detected" 2 "vect" { target vect_widen_mult_hi_to_si_pattern } } } */
58 /* { dg-final { scan-tree-dump-times "pattern recognized" 2 "vect" { target vect_widen_mult_hi_to_si_pattern } } } */
59 /* { dg-final { cleanup-tree-dump "vect" } } */
60