1 /* { dg-do run { target { powerpc*-*-linux* } } } */
2 /* { dg-require-effective-target vsx_hw } */
3 /* { dg-options "-O2 -mvsx" } */
9 #define ELEMENTS -1, 2, 0, -123456
10 #define SPLAT 0x01234567
12 vector
int sv
= (vector
int) { ELEMENTS
};
13 vector
int splat
= (vector
int) { SPLAT
, SPLAT
, SPLAT
, SPLAT
};
14 vector
int sv_global
, sp_global
;
15 static vector
int sv_static
, sp_static
;
16 static const int expected
[] = { ELEMENTS
};
18 extern void check (vector
int a
)
19 __attribute__((__noinline__
));
21 extern void check_splat (vector
int a
)
22 __attribute__((__noinline__
));
24 extern vector
int pack_reg (int a
, int b
, int c
, int d
)
25 __attribute__((__noinline__
));
27 extern vector
int pack_from_ptr (int *p_a
, int *p_b
, int *p_c
, int *p_d
)
28 __attribute__((__noinline__
));
30 extern vector
int pack_const (void)
31 __attribute__((__noinline__
));
33 extern void pack_ptr (vector
int *p
, int a
, int b
, int c
, int d
)
34 __attribute__((__noinline__
));
36 extern void pack_static (int a
, int b
, int c
, int d
)
37 __attribute__((__noinline__
));
39 extern void pack_global (int a
, int b
, int c
, int d
)
40 __attribute__((__noinline__
));
42 extern vector
int splat_reg (int a
)
43 __attribute__((__noinline__
));
45 extern vector
int splat_from_ptr (int *p
)
46 __attribute__((__noinline__
));
48 extern vector
int splat_const (void)
49 __attribute__((__noinline__
));
51 extern void splat_ptr (vector
int *p
, int a
)
52 __attribute__((__noinline__
));
54 extern void splat_static (int a
)
55 __attribute__((__noinline__
));
57 extern void splat_global (int a
)
58 __attribute__((__noinline__
));
65 for (i
= 0; i
< 4; i
++)
66 if (vec_extract (a
, i
) != expected
[i
])
71 check_splat (vector
int a
)
75 for (i
= 0; i
< 4; i
++)
76 if (vec_extract (a
, i
) != SPLAT
)
81 pack_reg (int a
, int b
, int c
, int d
)
83 return (vector
int) { a
, b
, c
, d
};
87 pack_from_ptr (int *p_a
, int *p_b
, int *p_c
, int *p_d
)
89 return (vector
int) { *p_a
, *p_b
, *p_c
, *p_d
};
95 return (vector
int) { ELEMENTS
};
99 pack_ptr (vector
int *p
, int a
, int b
, int c
, int d
)
101 *p
= (vector
int) { a
, b
, c
, d
};
105 pack_static (int a
, int b
, int c
, int d
)
107 sv_static
= (vector
int) { a
, b
, c
, d
};
111 pack_global (int a
, int b
, int c
, int d
)
113 sv_global
= (vector
int) { a
, b
, c
, d
};
119 return (vector
int) { a
, a
, a
, a
};
123 splat_from_ptr (int *p
)
125 return (vector
int) { *p
, *p
, *p
, *p
};
131 return (vector
int) { SPLAT
, SPLAT
, SPLAT
, SPLAT
};
135 splat_ptr (vector
int *p
, int a
)
137 *p
= (vector
int) { a
, a
, a
, a
};
143 sp_static
= (vector
int) { a
, a
, a
, a
};
149 sp_global
= (vector
int) { a
, a
, a
, a
};
156 int mem2
[4] = { ELEMENTS
};
160 check (pack_reg (ELEMENTS
));
162 check (pack_from_ptr (&mem2
[0], &mem2
[1], &mem2
[2], &mem2
[3]));
164 check (pack_const ());
166 pack_ptr (&sv2
, ELEMENTS
);
169 pack_static (ELEMENTS
);
172 pack_global (ELEMENTS
);
177 check_splat (splat_reg (SPLAT
));
179 check_splat (splat_from_ptr (&mem
));
181 check_splat (splat_const ());
183 splat_ptr (&sv2
, SPLAT
);
186 splat_static (SPLAT
);
187 check_splat (sp_static
);
189 splat_global (SPLAT
);
190 check_splat (sp_global
);