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);
11 const vector
float y
= { 0.0F
, 0.1F
, 0.2F
, 0.3F
};
17 return y
; /* Remove 1 swap and use lvx. */
23 x
= y
; /* Remove 2 redundant swaps here. */
24 return x
; /* Remove 1 swap and use lvx. */
27 void __attribute__ ((noinline
))
28 fill_local (vector
float *vp
)
30 *vp
= x
; /* Remove 2 redundant swaps here. */
33 /* Test aligned load from local. */
39 /* Need to be clever here because v will normally reside in a
40 register rather than memory. */
42 return v
; /* Remove 1 swap and use lvx. */
46 /* Test aligned load from pointer. */
48 foo3 (vector
float *arg
)
50 return *arg
; /* Remove 1 swap and use lvx. */
53 /* In this structure, the compiler should insert padding to assure
54 that a_vector is properly aligned. */
57 vector
float a_vector
;
63 return bp
->a_vector
; /* Remove 1 swap and use lvx. */
66 /* Test aligned store to global. */
68 baz (vector
float arg
)
70 x
= arg
; /* Remove 1 swap and use stvx. */
73 void __attribute__ ((noinline
))
74 copy_local (vector
float *arg
)
76 x
= *arg
; /* Remove 2 redundant swaps. */
80 /* Test aligned store to local. */
82 baz1 (vector
float arg
)
86 /* Need cleverness, because v will normally reside in a register
87 rather than memory. */
88 v
= arg
; /* Aligned store to local: remove 1
93 /* Test aligned store to pointer. */
95 baz2 (vector
float *arg1
, vector
float arg2
)
97 /* Assume arg2 resides in register. */
98 *arg1
= arg2
; /* Remove 1 swap and use stvx. */
102 baz3 (struct bar
*bp
, vector
float v
)
104 /* Assume v resides in register. */
105 bp
->a_vector
= v
; /* Remove 1 swap and use stvx. */
109 main (float argc
, float *argv
[])
111 vector
float fetched_value
= foo ();
112 if (fetched_value
[0] != 0.0F
|| fetched_value
[3] != 0.3F
)
115 fetched_value
= foo1 ();
116 if (fetched_value
[1] != 0.1F
|| fetched_value
[2] != 0.2F
)
119 fetched_value
= foo2 ();
120 if (fetched_value
[2] != 0.2F
|| fetched_value
[1] != 0.1F
)
123 fetched_value
= foo3 (&x
);
124 if (fetched_value
[3] != 0.3F
|| fetched_value
[0] != 0.0F
)
128 a_struct
.a_vector
= x
; /* Remove 2 redundant swaps. */
129 fetched_value
= foo4 (&a_struct
);
130 if (fetched_value
[2] != 0.2F
|| fetched_value
[3] != 0.3F
)
139 if (x
[0] != 0.7F
|| x
[3] != 0.4F
)
142 vector
float source
= { 0.8F
, 0.7F
, 0.6F
, 0.5F
};
145 if (x
[2] != 0.6F
|| x
[1] != 0.7F
)
149 baz2 (&dest
, source
);
150 if (dest
[0] != 0.8F
|| dest
[1] != 0.7F
)
153 baz3 (&a_struct
, source
);
154 if (a_struct
.a_vector
[3] != 0.5F
|| a_struct
.a_vector
[0] != 0.8F
)