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);
17 const vector
long long y
= { 1024, 2048 };
23 return y
; /* Remove 1 swap and use lvx. */
29 x
= y
; /* Remove 2 redundant swaps here. */
30 return x
; /* Remove 1 swap and use lvx. */
33 void __attribute__ ((noinline
))
34 fill_local (vector
long long *vp
)
36 *vp
= x
; /* Remove 2 redundant swaps here. */
39 /* Test aligned load from local. */
45 /* Need to be clever here because v will normally reside in a
46 register rather than memory. */
48 return v
; /* Remove 1 swap and use lvx. */
52 /* Test aligned load from pointer. */
54 foo3 (vector
long long *arg
)
56 return *arg
; /* Remove 1 swap and use lvx. */
59 /* In this structure, the compiler should insert padding to assure
60 that a_vector is properly aligned. */
63 vector
long long a_vector
;
69 return bp
->a_vector
; /* Remove 1 swap and use lvx. */
72 /* Test aligned store to global. */
74 baz (vector
long long arg
)
76 x
= arg
; /* Remove 1 swap and use stvx. */
79 void __attribute__ ((noinline
))
80 copy_local (vector
long long *arg
)
82 x
= *arg
; /* Remove 2 redundant swaps. */
86 /* Test aligned store to local. */
88 baz1 (vector
long long arg
)
92 /* Need cleverness, because v will normally reside in a register
93 rather than memory. */
94 v
= arg
; /* Aligned store to local: remove 1
99 /* Test aligned store to pointer. */
101 baz2 (vector
long long *arg1
, vector
long long arg2
)
103 /* Assume arg2 resides in register. */
104 *arg1
= arg2
; /* Remove 1 swap and use stvx. */
108 baz3 (struct bar
*bp
, vector
long long v
)
110 /* Assume v resides in register. */
111 bp
->a_vector
= v
; /* Remove 1 swap and use stvx. */
115 main (long long argc
, long long *argv
[])
117 vector
long long fetched_value
= foo ();
118 if (fetched_value
[0] != 1024 || fetched_value
[1] != 2048)
121 fetched_value
= foo1 ();
122 if (fetched_value
[1] != 2048 || fetched_value
[0] != 1024)
125 fetched_value
= foo2 ();
126 if (fetched_value
[0] != 1024 || fetched_value
[1] != 2048)
129 fetched_value
= foo3 (&x
);
130 if (fetched_value
[1] != 2048 || fetched_value
[0] != 1024)
134 a_struct
.a_vector
= x
; /* Remove 2 redundant swaps. */
135 fetched_value
= foo4 (&a_struct
);
136 if (fetched_value
[1] != 2048 || fetched_value
[0] != 1024)
143 if (x
[0] != 7096 || x
[1] != 6048)
146 vector
long long source
= { 8192, 7096};
149 if (x
[0] != 8192 || x
[1] != 7096)
152 vector
long long dest
;
153 baz2 (&dest
, source
);
154 if (dest
[0] != 8192 || dest
[1] != 7096)
157 baz3 (&a_struct
, source
);
158 if (a_struct
.a_vector
[1] != 7096 || a_struct
.a_vector
[0] != 8192)