1 /* { dg-do compile { target powerpc*-*-* } } */
2 /* { dg-require-effective-target powerpc_vsx_ok } */
3 /* { dg-options "-mvsx" } */
4 /* { dg-additional-options "-mdejagnu-cpu=power8" { target { ! has_arch_pwr8 } } } */
14 /* Endian considerations: The "high" half of a vector with n elements is the
15 first n/2 elements of the vector. For little endian, these elements are in
16 the rightmost half of the vector. For big endian, these elements are in the
17 leftmost half of the vector. */
22 vector
bool int vec_bi_arg
;
23 vector
bool long long vec_bll_result
, vec_bll_expected
;
25 vector
signed int vec_si_arg
;
26 vector
signed long long int vec_slli_result
, vec_slli_expected
;
27 vector
float vec_float_arg
;
28 vector
double vec_double_result
, vec_double_expected
;
35 /* Use of 'double' and ‘long long’ in AltiVec types requires -mvsx */
36 /* __builtin_altivec_vupkhsw and __builtin_altivec_vupklsw
37 requires the -mcpu=power8 -mvsx option */
39 vec_bi_arg
= (vector
bool int){ 0, 1, 1, 0 };
41 vec_bll_expected
= (vector
bool long long){ 0, 1 };
43 vec_bll_result
= vec_unpackh (vec_bi_arg
);
45 for (i
= 0; i
< 2; i
++) {
46 if (vec_bll_expected
[i
] != vec_bll_result
[i
])
48 printf("ERROR: vec_unpackh, vec_bll_expected[%d] = %d does not match vec_bll_result[%d] = %d\n",
49 i
, vec_bll_expected
[i
], i
, vec_bll_result
[i
]);
55 vec_bll_expected
= (vector
bool long long){ 1, 0 };
57 vec_bll_result
= vec_unpackl (vec_bi_arg
);
59 for (i
= 0; i
< 2; i
++) {
60 if (vec_bll_expected
[i
] != vec_bll_result
[i
])
62 printf("ERROR: vec_unpackl, vec_bll_expected[%d] = %d does not match vec_bll_result[%d] = %d\n",
63 i
, vec_bll_expected
[i
], i
, vec_bll_result
[i
]);
70 vec_si_arg
= (vector
signed int){ 0, 101, 202, 303 };
72 vec_slli_expected
= (vector
signed long long int){ 0, 101 };
74 vec_slli_result
= vec_unpackh (vec_si_arg
);
76 for (i
= 0; i
< 2; i
++) {
77 if (vec_slli_expected
[i
] != vec_slli_result
[i
])
79 printf("ERROR: vec_unpackh, vec_slli_expected[%d] = %d does not match vec_slli_result[%d] = %d\n",
80 i
, vec_slli_expected
[i
], i
, vec_slli_result
[i
]);
86 vec_slli_result
= vec_unpackl (vec_si_arg
);
87 vec_slli_expected
= (vector
signed long long int){ 202, 303 };
89 for (i
= 0; i
< 2; i
++) {
90 if (vec_slli_expected
[i
] != vec_slli_result
[i
])
92 printf("ERROR: vec_unpackl, vec_slli_expected[%d] = %d does not match vec_slli_result[%d] = %d\n",
93 i
, vec_slli_expected
[i
], i
, vec_slli_result
[i
]);
99 vec_float_arg
= (vector
float){ 0.0, 1.5, 2.5, 3.5 };
101 vec_double_expected
= (vector
double){ 0.0, 1.5 };
103 vec_double_result
= vec_unpackh (vec_float_arg
);
105 for (i
= 0; i
< 2; i
++) {
106 if (vec_double_expected
[i
] != vec_double_result
[i
])
109 printf("ERROR: vec_unpackh(), vec_double_expected[%d] = %f does not match vec_double_result[%d] = %f\n",
110 i
, vec_double_expected
[i
], i
, vec_double_result
[i
]);
111 conv_val
.d
= vec_double_result
[i
];
112 conv_exp
.d
= vec_double_expected
[i
];
113 printf(" vec_unpackh(), vec_double_expected[%d] = 0x%llx does not match vec_double_result[%d] = 0x%llx\n",
114 i
, conv_exp
.l
, i
,conv_val
.l
);
121 vec_double_expected
= (vector
double){ 2.5, 3.5 };
123 vec_double_result
= vec_unpackl (vec_float_arg
);
125 for (i
= 0; i
< 2; i
++) {
126 if (vec_double_expected
[i
] != vec_double_result
[i
])
129 printf("ERROR: vec_unpackl() vec_double_expected[%d] = %f does not match vec_double_result[%d] = %f\n",
130 i
, vec_double_expected
[i
], i
, vec_double_result
[i
]);
131 conv_val
.d
= vec_double_result
[i
];
132 conv_exp
.d
= vec_double_expected
[i
];
133 printf(" vec_unpackh(), vec_double_expected[%d] = 0x%llx does not match vec_double_result[%d] = 0x%llx\n",
134 i
, conv_exp
.l
, i
,conv_val
.l
);