1 /* { dg-do run { target { powerpc*-*-* } } } */
2 /* { dg-require-effective-target p8vector_hw } */
3 /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */
4 /* { dg-options "-mcpu=power8 -O3 " } */
8 extern void abort (void);
10 const vector
char y
= { 0, 1, 2, 3,
20 return y
; /* Remove 1 swap and use lvx. */
26 x
= y
; /* Remove 2 redundant swaps here. */
27 return x
; /* Remove 1 swap and use lvx. */
30 void __attribute__ ((noinline
))
31 fill_local (vector
char *vp
)
33 *vp
= x
; /* Remove 2 redundant swaps here. */
36 /* Test aligned load from local. */
42 /* Need to be clever here because v will normally reside in a
43 register rather than memory. */
45 return v
; /* Remove 1 swap and use lvx. */
49 /* Test aligned load from pointer. */
51 foo3 (vector
char *arg
)
53 return *arg
; /* Remove 1 swap and use lvx. */
56 /* In this structure, the compiler should insert padding to assure
57 that a_vector is properly aligned. */
66 return bp
->a_vector
; /* Remove 1 swap and use lvx. */
69 /* Test aligned store to global. */
73 x
= arg
; /* Remove 1 swap and use stvx. */
76 void __attribute__ ((noinline
))
77 copy_local (vector
char *arg
)
79 x
= *arg
; /* Remove 2 redundant swaps. */
83 /* Test aligned store to local. */
85 baz1 (vector
char arg
)
89 /* Need cleverness, because v will normally reside in a register
90 rather than memory. */
91 v
= arg
; /* Aligned store to local: remove 1
96 /* Test aligned store to pointer. */
98 baz2 (vector
char *arg1
, vector
char arg2
)
100 /* Assume arg2 resides in register. */
101 *arg1
= arg2
; /* Remove 1 swap and use stvx. */
105 baz3 (struct bar
*bp
, vector
char v
)
107 /* Assume v resides in register. */
108 bp
->a_vector
= v
; /* Remove 1 swap and use stvx. */
112 main (int argc
, char *argv
[])
114 vector
char fetched_value
= foo ();
115 if (fetched_value
[0] != 0 || fetched_value
[15] != 15)
118 fetched_value
= foo1 ();
119 if (fetched_value
[1] != 1 || fetched_value
[14] != 14)
122 fetched_value
= foo2 ();
123 if (fetched_value
[2] != 2 || fetched_value
[13] != 13)
126 fetched_value
= foo3 (&x
);
127 if (fetched_value
[3] != 3 || fetched_value
[12] != 12)
131 a_struct
.a_vector
= x
; /* Remove 2 redundant swaps. */
132 fetched_value
= foo4 (&a_struct
);
133 if (fetched_value
[4] != 4 || fetched_value
[11] != 11)
136 for (int i
= 0; i
< 16; i
++)
140 if (x
[0] != 15 || x
[15] != 0)
143 vector
char source
= { 8, 7, 6, 5, 4, 3, 2, 1,
144 0, 9, 10, 11, 12, 13, 14, 15 };
147 if (x
[3] != 5 || x
[8] != 0)
151 baz2 (&dest
, source
);
152 if (dest
[4] != 4 || dest
[1] != 7)
155 baz3 (&a_struct
, source
);
156 if (a_struct
.a_vector
[7] != 1 || a_struct
.a_vector
[15] != 15)