1 /* { dg-do run { target vect_cmdline_needed } } */
2 /* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-details -fvect-cost-model=dynamic" } */
3 /* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-details -fvect-cost-model=dynamic -mno-sse" { target { i?86-*-* x86_64-*-* } } } */
4
5 #include <stdlib.h>
6
7 #define N 128
8
9 #if __LONG_MAX__ == 2147483647
10 typedef short half_word;
11 #else
12 typedef int half_word;
13 #endif
14
main_1(int n,int * p)15 int main_1 (int n, int *p)
16 {
17 int i;
18 half_word ib[N];
19 half_word ia[N];
20 int k;
21
22 for (i = 0; i < N; i++)
23 {
24 ia[i] = n;
25 }
26
27 /* check results: */
28 for (i = 0; i < N; i++)
29 {
30 if (ia[i] != n)
31 abort ();
32 }
33
34 k = *p;
35 for (i = 0; i < N; i++)
36 {
37 ib[i] = k;
38 }
39
40 /* check results: */
41 for (i = 0; i < N; i++)
42 {
43 if (ib[i] != k)
44 abort ();
45 }
46
47 return 0;
48 }
49
50 static volatile int n = 1;
51
main(void)52 int main (void)
53 {
54 return main_1 (n + 2, (int *) &n);
55 }
56
57 /* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" { target { ! avr-*-* } } } } */
58 /* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" { target { ! avr-*-* } } } } */
59