PR middle-end/77357 - strlen of constant strings not folded
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / pr46009.c
blob9649e2fb4bbfd74e134a9ef3d068d50b9bcb86c0
1 /* PR tree-optimization/46009 */
2 /* { dg-require-effective-target vect_int } */
4 #include "tree-vect.h"
6 int a[1024] __attribute__((aligned));
7 int b[1024] __attribute__((aligned));
8 int c[1024] __attribute__((aligned));
9 int d[1024] __attribute__((aligned));
10 int e[1024] __attribute__((aligned));
12 void __attribute__((noinline))
13 foo (void)
15 int i, g;
16 for (i = 0; i < 1024; i++)
18 g = a[i] + b[i] + c[i] * d[i];;
19 e[i] = g < 10 ? 1 : g;
23 void __attribute__((noinline))
24 bar (void)
26 int i, g;
27 for (i = 0; i < 1024; i++)
29 g = a[i] + b[i] + c[i] * d[i];;
30 if (g < 10)
31 e[i] = 1;
32 else
33 e[i] = g;
37 int
38 main (void)
40 int i;
41 check_vect ();
42 for (i = 0; i < 1024; i++)
44 asm volatile ("" : "+r" (i));
45 a[i] = i % 10;
46 b[i] = i % 10;
47 c[i] = 1;
48 d[i] = -1;
49 e[i] = -1;
51 foo ();
52 for (i = 0; i < 1024; i++)
54 int g;
55 asm volatile ("" : "+r" (i));
56 g = 2 * (i % 10) - 1;
57 if (e[i] != (g < 10 ? 1 : g))
58 abort ();
59 e[i] = -1;
61 bar ();
62 for (i = 0; i < 1024; i++)
64 int g;
65 asm volatile ("" : "+r" (i));
66 g = 2 * (i % 10) - 1;
67 if (e[i] != (g < 10 ? 1 : g))
68 abort ();
70 return 0;
73 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { target vect_int_mult } } } */