OSDN Git Service

Fix 50988 testsuite failures
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.target / sparc / vec-init-1.inc
1 typedef int __v1si __attribute__ ((__vector_size__ (4)));
2 typedef int __v2si __attribute__ ((__vector_size__ (8)));
3 typedef short __v2hi __attribute__ ((__vector_size__ (4)));
4 typedef short __v4hi __attribute__ ((__vector_size__ (8)));
5 typedef unsigned char __v4qi __attribute__ ((__vector_size__ (4)));
6 typedef unsigned char __v8qi __attribute__ ((__vector_size__ (8)));
7
8 extern void abort (void);
9
10 static void
11 compare64 (void *p, unsigned long long val)
12 {
13   if (*(unsigned long long *)p != val)
14     abort();
15 }
16
17 static void
18 compare32 (void *p, unsigned int val)
19 {
20   if (*(unsigned int *)p != val)
21     abort();
22 }
23
24 static void
25 test_v8qi (unsigned char x)
26 {
27   __v8qi v = { x, x, x, x, x, x, x, x };
28
29   compare64(&v, 0x4444444444444444ULL);
30 }
31
32 static void
33 test_v4qi (unsigned char x)
34 {
35   __v4qi v = { x, x, x, x };
36
37   compare32(&v, 0x44444444);
38 }
39
40 static void
41 test_v4hi (unsigned short x)
42 {
43   __v4hi v = { x, x, x, x, };
44
45   compare64(&v, 0x3344334433443344ULL);
46 }
47
48 static void
49 test_v2hi (unsigned short x)
50 {
51   __v2hi v = { x, x, };
52
53   compare32(&v, 0x33443344);
54 }
55
56 static void
57 test_v2si (unsigned int x)
58 {
59   __v2si v = { x, x, };
60
61   compare64(&v, 0x1122334411223344ULL);
62 }
63
64 static void
65 test_v1si (unsigned int x)
66 {
67   __v1si v = { x };
68
69   compare32(&v, 0x11223344);
70 }
71
72 unsigned char x8 = 0x44;
73 unsigned short x16 = 0x3344;
74 unsigned int x32 = 0x11223344;
75
76 int main(void)
77 {
78   test_v8qi (x8);
79   test_v4qi (x8);
80   test_v4hi (x16);
81   test_v2hi (x16);
82   test_v2si (x32);
83   test_v1si (x32);
84   return 0;
85 }