aarch64: Fix reg_is_wrapped_separately array size [PR100211]
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / swaps-p8-37.c
blobe52d804f5fa81ac1cc7513eb4bc48e3fe075a7c8
1 /* { dg-do run } */
2 /* { dg-require-effective-target p8vector_hw } */
3 /* { dg-options "-mdejagnu-cpu=power8 -O3 " } */
5 #include <altivec.h>
7 extern void abort (void);
9 vector float x;
10 vector float y = { 0.0F, 0.1F, 0.2F, 0.3F };
11 vector float z;
13 vector float
14 foo (void)
16 return y; /* Remove 1 swap and use lvx. */
19 vector float
20 foo1 (void)
22 x = y; /* Remove 2 redundant swaps here. */
23 return x; /* Remove 1 swap and use lvx. */
26 void __attribute__ ((noinline))
27 fill_local (vector float *vp)
29 *vp = x; /* Remove 2 redundant swaps here. */
32 /* Test aligned load from local. */
33 vector float
34 foo2 (void)
36 vector float v;
38 /* Need to be clever here because v will normally reside in a
39 register rather than memory. */
40 fill_local (&v);
41 return v; /* Remove 1 swap and use lvx. */
45 /* Test aligned load from pointer. */
46 vector float
47 foo3 (vector float *arg)
49 return *arg; /* Remove 1 swap and use lvx. */
52 /* In this structure, the compiler should insert padding to assure
53 that a_vector is properly aligned. */
54 struct bar {
55 short a_field;
56 vector float a_vector;
59 vector float
60 foo4 (struct bar *bp)
62 return bp->a_vector; /* Remove 1 swap and use lvx. */
65 /* Test aligned store to global. */
66 void
67 baz (vector float arg)
69 x = arg; /* Remove 1 swap and use stvx. */
72 void __attribute__ ((noinline))
73 copy_local (vector float *arg)
75 x = *arg; /* Remove 2 redundant swaps. */
79 /* Test aligned store to local. */
80 void
81 baz1 (vector float arg)
83 vector float v;
85 /* Need cleverness, because v will normally reside in a register
86 rather than memory. */
87 v = arg; /* Aligned store to local: remove 1
88 swap and use stvx. */
89 copy_local (&v);
92 /* Test aligned store to pointer. */
93 void
94 baz2 (vector float *arg1, vector float arg2)
96 /* Assume arg2 resides in register. */
97 *arg1 = arg2; /* Remove 1 swap and use stvx. */
100 void
101 baz3 (struct bar *bp, vector float v)
103 /* Assume v resides in register. */
104 bp->a_vector = v; /* Remove 1 swap and use stvx. */
108 main (float argc, float *argv[])
110 vector float fetched_value = foo ();
111 if (fetched_value[0] != 0.0F || fetched_value[3] != 0.3F)
112 abort ();
114 fetched_value = foo1 ();
115 if (fetched_value[1] != 0.1F || fetched_value[2] != 0.2F)
116 abort ();
118 fetched_value = foo2 ();
119 if (fetched_value[2] != 0.2F || fetched_value[1] != 0.1F)
120 abort ();
122 fetched_value = foo3 (&x);
123 if (fetched_value[3] != 0.3F || fetched_value[0] != 0.0F)
124 abort ();
126 struct bar a_struct;
127 a_struct.a_vector = x; /* Remove 2 redundant swaps. */
128 fetched_value = foo4 (&a_struct);
129 if (fetched_value[2] != 0.2F || fetched_value[3] != 0.3F)
130 abort ();
132 z[0] = 0.7F;
133 z[1] = 0.6F;
134 z[2] = 0.5F;
135 z[3] = 0.4F;
137 baz (z);
138 if (x[0] != 0.7F || x[3] != 0.4F)
139 abort ();
141 vector float source = { 0.8F, 0.7F, 0.6F, 0.5F };
143 baz1 (source);
144 if (x[2] != 0.6F || x[1] != 0.7F)
145 abort ();
147 vector float dest;
148 baz2 (&dest, source);
149 if (dest[0] != 0.8F || dest[1] != 0.7F)
150 abort ();
152 baz3 (&a_struct, source);
153 if (a_struct.a_vector[3] != 0.5F || a_struct.a_vector[0] != 0.8F)
154 abort ();
156 return 0;