OSDN Git Service

Cleanup double words.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / vect / pr46009.c
1 /* PR tree-optimization/46009 */
2 /* { dg-require-effective-target vect_int } */
3
4 #include "tree-vect.h"
5
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));
11
12 void __attribute__((noinline))
13 foo (void)
14 {
15   int i, g;
16   for (i = 0; i < 1024; i++)
17     {
18       g = a[i] + b[i] + c[i] * d[i];;
19       e[i] = g < 10 ? 1 : g;
20     }
21 }
22
23 void __attribute__((noinline))
24 bar (void)
25 {
26   int i, g;
27   for (i = 0; i < 1024; i++)
28     {
29       g = a[i] + b[i] + c[i] * d[i];;
30       if (g < 10)
31         e[i] = 1;
32       else
33         e[i] = g;
34     }
35 }
36
37 int
38 main (void)
39 {
40   int i;
41   check_vect ();
42   for (i = 0; i < 1024; i++)
43     {
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;
50     }
51   foo ();
52   for (i = 0; i < 1024; i++)
53     {
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;
60     }
61   bar ();
62   for (i = 0; i < 1024; i++)
63     {
64       int g;
65       asm volatile ("" : "+r" (i));
66       g = 2 * (i % 10) - 1;
67       if (e[i] != (g < 10 ? 1 : g))
68         abort ();
69     }
70   return 0;
71 }
72
73 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { target vect_int_mult } } } */
74 /* { dg-final { cleanup-tree-dump "vect" } } */