2 /* { dg-require-effective-target vsx_hw } */
3 /* { dg-options "-O2 -mvsx" } */
9 #define ELEMENTS -1, 2, 0, -32768, 32767, 53, 1, 16000
12 vector
short sv
= (vector
short) { ELEMENTS
};
13 vector
short splat
= (vector
short) { SPLAT
, SPLAT
, SPLAT
, SPLAT
,
14 SPLAT
, SPLAT
, SPLAT
, SPLAT
};
15 vector
short sv_global
, sp_global
;
16 static vector
short sv_static
, sp_static
;
17 static short expected
[] = { ELEMENTS
};
18 static short splat_expected
= SPLAT
;
20 extern void check (vector
short a
)
21 __attribute__((__noinline__
));
23 extern void check_splat (vector
short a
)
24 __attribute__((__noinline__
));
26 extern vector
short pack_reg (short a
, short b
, short c
, short d
,
27 short e
, short f
, short g
, short h
)
28 __attribute__((__noinline__
));
30 extern vector
short pack_from_ptr (short *p_a
, short *p_b
,
31 short *p_c
, short *p_d
,
32 short *p_e
, short *p_f
,
33 short *p_g
, short *p_h
)
34 __attribute__((__noinline__
));
36 extern vector
short pack_const (void)
37 __attribute__((__noinline__
));
39 extern void pack_ptr (vector
short *p
,
40 short a
, short b
, short c
, short d
,
41 short e
, short f
, short g
, short h
)
42 __attribute__((__noinline__
));
44 extern void pack_static (short a
, short b
, short c
, short d
,
45 short e
, short f
, short g
, short h
)
46 __attribute__((__noinline__
));
48 extern void pack_global (short a
, short b
, short c
, short d
,
49 short e
, short f
, short g
, short h
)
50 __attribute__((__noinline__
));
52 extern vector
short splat_reg (short a
)
53 __attribute__((__noinline__
));
55 extern vector
short splat_from_ptr (short *p_a
)
56 __attribute__((__noinline__
));
58 extern vector
short splat_const (void)
59 __attribute__((__noinline__
));
61 extern void splat_ptr (vector
short *p
, short a
)
62 __attribute__((__noinline__
));
64 extern void splat_static (short a
)
65 __attribute__((__noinline__
));
67 extern void splat_global (short a
)
68 __attribute__((__noinline__
));
71 check (vector
short a
)
75 for (i
= 0; i
< 8; i
++)
76 if (vec_extract (a
, i
) != expected
[i
])
81 check_splat (vector
short a
)
85 for (i
= 0; i
< 8; i
++)
86 if (vec_extract (a
, i
) != SPLAT
)
91 pack_reg (short a
, short b
, short c
, short d
,
92 short e
, short f
, short g
, short h
)
94 return (vector
short) { a
, b
, c
, d
, e
, f
, g
, h
};
98 pack_from_ptr (short *p_a
, short *p_b
, short *p_c
, short *p_d
,
99 short *p_e
, short *p_f
, short *p_g
, short *p_h
)
101 return (vector
short) { *p_a
, *p_b
, *p_c
, *p_d
,
102 *p_e
, *p_f
, *p_g
, *p_h
};
108 return (vector
short) { ELEMENTS
};
112 pack_ptr (vector
short *p
,
113 short a
, short b
, short c
, short d
,
114 short e
, short f
, short g
, short h
)
116 *p
= (vector
short) { a
, b
, c
, d
, e
, f
, g
, h
};
120 pack_static (short a
, short b
, short c
, short d
,
121 short e
, short f
, short g
, short h
)
123 sv_static
= (vector
short) { a
, b
, c
, d
, e
, f
, g
, h
};
127 pack_global (short a
, short b
, short c
, short d
,
128 short e
, short f
, short g
, short h
)
130 sv_global
= (vector
short) { a
, b
, c
, d
, e
, f
, g
, h
};
136 return (vector
short) { a
, a
, a
, a
, a
, a
, a
, a
};
140 splat_from_ptr (short *p_a
)
142 return (vector
short) { *p_a
, *p_a
, *p_a
, *p_a
,
143 *p_a
, *p_a
, *p_a
, *p_a
};
149 return (vector
short) { SPLAT
, SPLAT
, SPLAT
, SPLAT
,
150 SPLAT
, SPLAT
, SPLAT
, SPLAT
};
154 splat_ptr (vector
short *p
, short a
)
156 *p
= (vector
short) { a
, a
, a
, a
, a
, a
, a
, a
};
160 splat_static (short a
)
162 sp_static
= (vector
short) { a
, a
, a
, a
, a
, a
, a
, a
};
166 splat_global (short a
)
168 sp_global
= (vector
short) { a
, a
, a
, a
, a
, a
, a
, a
};
173 vector
short sv2
, sv3
;
177 check (pack_reg (ELEMENTS
));
179 check (pack_from_ptr (&expected
[0], &expected
[1], &expected
[2],
180 &expected
[3], &expected
[4], &expected
[5],
181 &expected
[6], &expected
[7]));
183 check (pack_const ());
185 pack_ptr (&sv2
, ELEMENTS
);
188 pack_static (ELEMENTS
);
191 pack_global (ELEMENTS
);
196 check_splat (splat_reg (SPLAT
));
198 check_splat (splat_from_ptr (&splat_expected
));
200 check_splat (splat_const ());
202 splat_ptr (&sv2
, SPLAT
);
205 splat_static (SPLAT
);
206 check_splat (sp_static
);
208 splat_global (SPLAT
);
209 check_splat (sp_global
);