1 /* { dg-do compile } */
2 /* { dg-require-effective-target powerpc_vsx_ok } */
3 /* { dg-options "-mdejagnu-cpu=power8 -mvsx -O3 " } */
5 /* Previous versions of this test required that the assembler does not
6 contain xxpermdi or xxswapd. However, with the more sophisticated
7 code generation used today, it is now possible that xxpermdi (aka
8 xxswapd) show up without being part of a lxvd2x or stxvd2x
13 extern void abort (void);
15 const vector
char y
= { 0, 1, 2, 3,
25 return y
; /* Remove 1 swap and use lvx. */
31 x
= y
; /* Remove 2 redundant swaps here. */
32 return x
; /* Remove 1 swap and use lvx. */
35 void __attribute__ ((noinline
))
36 fill_local (vector
char *vp
)
38 *vp
= x
; /* Remove 2 redundant swaps here. */
41 /* Test aligned load from local. */
47 /* Need to be clever here because v will normally reside in a
48 register rather than memory. */
50 return v
; /* Remove 1 swap and use lvx. */
54 /* Test aligned load from pointer. */
56 foo3 (vector
char *arg
)
58 return *arg
; /* Remove 1 swap and use lvx. */
61 /* In this structure, the compiler should insert padding to assure
62 that a_vector is properly aligned. */
71 return bp
->a_vector
; /* Remove 1 swap and use lvx. */
74 /* Test aligned store to global. */
78 x
= arg
; /* Remove 1 swap and use stvx. */
81 void __attribute__ ((noinline
))
82 copy_local (vector
char *arg
)
84 x
= *arg
; /* Remove 2 redundant swaps. */
88 /* Test aligned store to local. */
90 baz1 (vector
char arg
)
94 /* Need cleverness, because v will normally reside in a register
95 rather than memory. */
96 v
= arg
; /* Aligned store to local: remove 1
101 /* Test aligned store to pointer. */
103 baz2 (vector
char *arg1
, vector
char arg2
)
105 /* Assume arg2 resides in register. */
106 *arg1
= arg2
; /* Remove 1 swap and use stvx. */
110 baz3 (struct bar
*bp
, vector
char v
)
112 /* Assume v resides in register. */
113 bp
->a_vector
= v
; /* Remove 1 swap and use stvx. */
117 main (int argc
, char *argv
[])
119 vector
char fetched_value
= foo ();
120 if (fetched_value
[0] != 0 || fetched_value
[15] != 15)
123 fetched_value
= foo1 ();
124 if (fetched_value
[1] != 1 || fetched_value
[14] != 14)
127 fetched_value
= foo2 ();
128 if (fetched_value
[2] != 2 || fetched_value
[13] != 13)
131 fetched_value
= foo3 (&x
);
132 if (fetched_value
[3] != 3 || fetched_value
[12] != 12)
136 a_struct
.a_vector
= x
; /* Remove 2 redundant swaps. */
137 fetched_value
= foo4 (&a_struct
);
138 if (fetched_value
[4] != 4 || fetched_value
[11] != 11)
141 for (int i
= 0; i
< 16; i
++)
145 if (x
[0] != 15 || x
[15] != 0)
148 vector
char source
= { 8, 7, 6, 5, 4, 3, 2, 1,
149 0, 9, 10, 11, 12, 13, 14, 15 };
152 if (x
[3] != 5 || x
[8] != 0)
156 baz2 (&dest
, source
);
157 if (dest
[4] != 4 || dest
[1] != 7)
160 baz3 (&a_struct
, source
);
161 if (a_struct
.a_vector
[7] != 1 || a_struct
.a_vector
[15] != 15)