2 /* { dg-require-effective-target p8vector_hw } */
3 /* { dg-options "-mdejagnu-cpu=power8 -O3 " } */
7 extern void abort (void);
9 const vector
char y
= { 0, 1, 2, 3,
19 return y
; /* Remove 1 swap and use lvx. */
25 x
= y
; /* Remove 2 redundant swaps here. */
26 return x
; /* Remove 1 swap and use lvx. */
29 void __attribute__ ((noinline
))
30 fill_local (vector
char *vp
)
32 *vp
= x
; /* Remove 2 redundant swaps here. */
35 /* Test aligned load from local. */
41 /* Need to be clever here because v will normally reside in a
42 register rather than memory. */
44 return v
; /* Remove 1 swap and use lvx. */
48 /* Test aligned load from pointer. */
50 foo3 (vector
char *arg
)
52 return *arg
; /* Remove 1 swap and use lvx. */
55 /* In this structure, the compiler should insert padding to assure
56 that a_vector is properly aligned. */
65 return bp
->a_vector
; /* Remove 1 swap and use lvx. */
68 /* Test aligned store to global. */
72 x
= arg
; /* Remove 1 swap and use stvx. */
75 void __attribute__ ((noinline
))
76 copy_local (vector
char *arg
)
78 x
= *arg
; /* Remove 2 redundant swaps. */
82 /* Test aligned store to local. */
84 baz1 (vector
char arg
)
88 /* Need cleverness, because v will normally reside in a register
89 rather than memory. */
90 v
= arg
; /* Aligned store to local: remove 1
95 /* Test aligned store to pointer. */
97 baz2 (vector
char *arg1
, vector
char arg2
)
99 /* Assume arg2 resides in register. */
100 *arg1
= arg2
; /* Remove 1 swap and use stvx. */
104 baz3 (struct bar
*bp
, vector
char v
)
106 /* Assume v resides in register. */
107 bp
->a_vector
= v
; /* Remove 1 swap and use stvx. */
111 main (int argc
, char *argv
[])
113 vector
char fetched_value
= foo ();
114 if (fetched_value
[0] != 0 || fetched_value
[15] != 15)
117 fetched_value
= foo1 ();
118 if (fetched_value
[1] != 1 || fetched_value
[14] != 14)
121 fetched_value
= foo2 ();
122 if (fetched_value
[2] != 2 || fetched_value
[13] != 13)
125 fetched_value
= foo3 (&x
);
126 if (fetched_value
[3] != 3 || fetched_value
[12] != 12)
130 a_struct
.a_vector
= x
; /* Remove 2 redundant swaps. */
131 fetched_value
= foo4 (&a_struct
);
132 if (fetched_value
[4] != 4 || fetched_value
[11] != 11)
135 for (int i
= 0; i
< 16; i
++)
139 if (x
[0] != 15 || x
[15] != 0)
142 vector
char source
= { 8, 7, 6, 5, 4, 3, 2, 1,
143 0, 9, 10, 11, 12, 13, 14, 15 };
146 if (x
[3] != 5 || x
[8] != 0)
150 baz2 (&dest
, source
);
151 if (dest
[4] != 4 || dest
[1] != 7)
154 baz3 (&a_struct
, source
);
155 if (a_struct
.a_vector
[7] != 1 || a_struct
.a_vector
[15] != 15)