1 /* { dg-do compile { target { powerpc64le-*-* } } } */
2 /* { dg-require-effective-target powerpc_p8vector_ok } */
3 /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */
4 /* { dg-options "-mcpu=power8 -O3 " } */
6 /* Previous versions of this test required that the assembler does not
7 contain xxpermdi or xxswapd. However, with the more sophisticated
8 code generation used today, it is now possible that xxpermdi (aka
9 xxswapd) show up without being part of a lxvd2x or stxvd2x
14 extern void abort (void);
16 const vector
char y
= { 0, 1, 2, 3,
26 return y
; /* Remove 1 swap and use lvx. */
32 x
= y
; /* Remove 2 redundant swaps here. */
33 return x
; /* Remove 1 swap and use lvx. */
36 void __attribute__ ((noinline
))
37 fill_local (vector
char *vp
)
39 *vp
= x
; /* Remove 2 redundant swaps here. */
42 /* Test aligned load from local. */
48 /* Need to be clever here because v will normally reside in a
49 register rather than memory. */
51 return v
; /* Remove 1 swap and use lvx. */
55 /* Test aligned load from pointer. */
57 foo3 (vector
char *arg
)
59 return *arg
; /* Remove 1 swap and use lvx. */
62 /* In this structure, the compiler should insert padding to assure
63 that a_vector is properly aligned. */
72 return bp
->a_vector
; /* Remove 1 swap and use lvx. */
75 /* Test aligned store to global. */
79 x
= arg
; /* Remove 1 swap and use stvx. */
82 void __attribute__ ((noinline
))
83 copy_local (vector
char *arg
)
85 x
= *arg
; /* Remove 2 redundant swaps. */
89 /* Test aligned store to local. */
91 baz1 (vector
char arg
)
95 /* Need cleverness, because v will normally reside in a register
96 rather than memory. */
97 v
= arg
; /* Aligned store to local: remove 1
102 /* Test aligned store to pointer. */
104 baz2 (vector
char *arg1
, vector
char arg2
)
106 /* Assume arg2 resides in register. */
107 *arg1
= arg2
; /* Remove 1 swap and use stvx. */
111 baz3 (struct bar
*bp
, vector
char v
)
113 /* Assume v resides in register. */
114 bp
->a_vector
= v
; /* Remove 1 swap and use stvx. */
118 main (int argc
, char *argv
[])
120 vector
char fetched_value
= foo ();
121 if (fetched_value
[0] != 0 || fetched_value
[15] != 15)
124 fetched_value
= foo1 ();
125 if (fetched_value
[1] != 1 || fetched_value
[14] != 14)
128 fetched_value
= foo2 ();
129 if (fetched_value
[2] != 2 || fetched_value
[13] != 13)
132 fetched_value
= foo3 (&x
);
133 if (fetched_value
[3] != 3 || fetched_value
[12] != 12)
137 a_struct
.a_vector
= x
; /* Remove 2 redundant swaps. */
138 fetched_value
= foo4 (&a_struct
);
139 if (fetched_value
[4] != 4 || fetched_value
[11] != 11)
142 for (int i
= 0; i
< 16; i
++)
146 if (x
[0] != 15 || x
[15] != 0)
149 vector
char source
= { 8, 7, 6, 5, 4, 3, 2, 1,
150 0, 9, 10, 11, 12, 13, 14, 15 };
153 if (x
[3] != 5 || x
[8] != 0)
157 baz2 (&dest
, source
);
158 if (dest
[4] != 4 || dest
[1] != 7)
161 baz3 (&a_struct
, source
);
162 if (a_struct
.a_vector
[7] != 1 || a_struct
.a_vector
[15] != 15)