| 1 |
/* { dg-do run { target vmx_hw } } */ |
| 2 |
/* { dg-do compile { target { ! vmx_hw } } } */ |
| 3 |
/* { dg-options "-O2 -maltivec" } */ |
| 4 |
/* { dg-require-effective-target powerpc_altivec } */ |
| 5 |
|
| 6 |
#include <altivec.h> |
| 7 |
|
| 8 |
#ifdef DEBUG |
| 9 |
#include <stdio.h> |
| 10 |
#endif |
| 11 |
|
| 12 |
/* Endian considerations: The "high" half of a vector with n elements is the |
| 13 |
first n/2 elements of the vector. For little endian, these elements are in |
| 14 |
the rightmost half of the vector. For big endian, these elements are in the |
| 15 |
leftmost half of the vector. */ |
| 16 |
|
| 17 |
|
| 18 |
void abort (void); |
| 19 |
|
| 20 |
int main () |
| 21 |
{ |
| 22 |
int i; |
| 23 |
vector bool short vec_bs_arg; |
| 24 |
vector bool short vec_bs_result, vec_bs_expected; |
| 25 |
vector bool int vec_bi_arg; |
| 26 |
vector bool int vec_bi_result, vec_bi_expected; |
| 27 |
vector bool char vec_bc_arg; |
| 28 |
vector bool char vec_bc_result, vec_bc_expected; |
| 29 |
vector signed short vec_ss_arg; |
| 30 |
vector signed short vec_ss_result, vec_ss_expected; |
| 31 |
vector signed int vec_si_arg; |
| 32 |
vector signed int vec_si_result, vec_si_expected; |
| 33 |
vector signed char vec_sc_arg; |
| 34 |
vector signed char vec_sc_result, vec_sc_expected; |
| 35 |
vector pixel vec_pixel_arg; |
| 36 |
vector unsigned int vec_ui_result, vec_ui_expected; |
| 37 |
|
| 38 |
vec_bs_arg = (vector bool short){ 0, 101, 202, 303, |
| 39 |
404, 505, 606, 707 }; |
| 40 |
vec_bi_expected = (vector bool int){ 0, 101, 202, 303 }; |
| 41 |
|
| 42 |
vec_bi_result = vec_unpackh (vec_bs_arg); |
| 43 |
|
| 44 |
for (i = 0; i < 4; i++) { |
| 45 |
if (vec_bi_expected[i] != vec_bi_result[i]) |
| 46 |
#if DEBUG |
| 47 |
printf("ERROR: vec_unpackh(), vec_bi_expected[%d] = %d does not match vec_bi_result[%d] = %d\n", |
| 48 |
i, vec_bi_expected[i], i, vec_bi_result[i]); |
| 49 |
#else |
| 50 |
abort(); |
| 51 |
#endif |
| 52 |
} |
| 53 |
|
| 54 |
vec_bi_expected = (vector bool int){ 404, 505, 606, 707 }; |
| 55 |
vec_bi_result = vec_unpackl (vec_bs_arg); |
| 56 |
|
| 57 |
for (i = 0; i < 4; i++) { |
| 58 |
if (vec_bi_expected[i] != vec_bi_result[i]) |
| 59 |
#if DEBUG |
| 60 |
printf("ERROR: vec_unpackl(), vec_bi_expected[%d] = %d does not match vec_bi_result[%d] = %d\n", |
| 61 |
i, vec_bi_expected[i], i, vec_bi_result[i]); |
| 62 |
#else |
| 63 |
abort(); |
| 64 |
#endif |
| 65 |
} |
| 66 |
|
| 67 |
|
| 68 |
vec_ss_arg = (vector signed short){ 0, 101, 202, 303, |
| 69 |
404, 505, 606, 707 }; |
| 70 |
vec_si_expected = (vector signed int){ 0, 101, 202, 303 }; |
| 71 |
|
| 72 |
vec_si_result = vec_unpackh (vec_ss_arg); |
| 73 |
|
| 74 |
for (i = 0; i < 4; i++) { |
| 75 |
if (vec_si_expected[i] != vec_si_result[i]) |
| 76 |
#if DEBUG |
| 77 |
printf("ERROR: vec_unpackh(), vec_si_expected[%d] = %d does not match vec_si_result[%d] = %d\n", |
| 78 |
i, vec_si_expected[i], i, vec_si_result[i]); |
| 79 |
#else |
| 80 |
abort(); |
| 81 |
#endif |
| 82 |
} |
| 83 |
|
| 84 |
vec_si_expected = (vector signed int){ 404, 505, 606, 707 }; |
| 85 |
|
| 86 |
vec_si_result = vec_unpackl (vec_ss_arg); |
| 87 |
|
| 88 |
for (i = 0; i < 4; i++) { |
| 89 |
if (vec_si_expected[i] != vec_si_result[i]) |
| 90 |
#if DEBUG |
| 91 |
printf("ERROR: vec_unpackl(), vec_si_expected[%d] = %d does not match vec_si_result[%d] = %d\n", |
| 92 |
i, vec_si_expected[i], i, vec_si_result[i]); |
| 93 |
#else |
| 94 |
abort(); |
| 95 |
#endif |
| 96 |
} |
| 97 |
|
| 98 |
|
| 99 |
vec_pixel_arg = (vector pixel){ 0x0, 0x65, 0xca, 0x12f, |
| 100 |
0x194, 0x1f9, 0x25e, 0x2c3 }; |
| 101 |
vec_ui_expected = (vector unsigned int){ 0x0, 0x305, 0x60a, 0x90f }; |
| 102 |
|
| 103 |
vec_ui_result = vec_unpackh (vec_pixel_arg); |
| 104 |
|
| 105 |
for (i = 0; i < 4; i++) { |
| 106 |
if (vec_ui_expected[i] != vec_ui_result[i]) |
| 107 |
#if DEBUG |
| 108 |
printf("ERROR: vec_unpackh(), vec_ui_expected[%d] = 0x%x does not match vec_ui_result[%d] = 0x%x\n", |
| 109 |
i, vec_ui_expected[i], i, vec_ui_result[i]); |
| 110 |
#else |
| 111 |
abort(); |
| 112 |
#endif |
| 113 |
} |
| 114 |
|
| 115 |
vec_ui_expected = (vector unsigned int){ 0xc14, 0xf19, 0x121e, 0x1603 }; |
| 116 |
|
| 117 |
vec_ui_result = vec_unpackl (vec_pixel_arg); |
| 118 |
|
| 119 |
for (i = 0; i < 4; i++) { |
| 120 |
if (vec_ui_expected[i] != vec_ui_result[i]) |
| 121 |
#if DEBUG |
| 122 |
printf("ERROR: vec_unpackl(), vec_ui_expected[%d] = 0x%x does not match vec_ui_result[%d] = 0x%x\n", |
| 123 |
i, vec_ui_expected[i], i, vec_ui_result[i]); |
| 124 |
#else |
| 125 |
abort(); |
| 126 |
#endif |
| 127 |
} |
| 128 |
|
| 129 |
|
| 130 |
vec_bc_arg = (vector bool char){ 0, 1, 0, 1, 0, 1, 0, 1, |
| 131 |
0, 0, 1, 1, 0, 0, 1, 1 }; |
| 132 |
|
| 133 |
vec_bs_expected = (vector bool short){ 0, 1, 0, 1, 0, 1, 0, 1 }; |
| 134 |
|
| 135 |
vec_bs_result = vec_unpackh (vec_bc_arg); |
| 136 |
|
| 137 |
for (i = 0; i < 8; i++) { |
| 138 |
if (vec_bs_expected[i] != vec_bs_result[i]) |
| 139 |
#if DEBUG |
| 140 |
printf("ERROR: vec_unpackh(), vec_bs_expected[%d] = %d does not match vec_bs_result[%d] = %d\n", |
| 141 |
i, vec_bs_expected[i], i, vec_bs_result[i]); |
| 142 |
#else |
| 143 |
abort(); |
| 144 |
#endif |
| 145 |
} |
| 146 |
|
| 147 |
vec_bs_expected = (vector bool short){ 0, 0, 1, 1, 0, 0, 1, 1 }; |
| 148 |
|
| 149 |
vec_bs_result = vec_unpackl (vec_bc_arg); |
| 150 |
|
| 151 |
for (i = 0; i < 8; i++) { |
| 152 |
if (vec_bs_expected[i] != vec_bs_result[i]) |
| 153 |
#if DEBUG |
| 154 |
printf("ERROR: vec_unpackh(), vec_bs_expected[%d] = %d does not match vec_bs_result[%d] = %d\n", |
| 155 |
i, vec_bs_expected[i], i, vec_bs_result[i]); |
| 156 |
#else |
| 157 |
abort(); |
| 158 |
#endif |
| 159 |
} |
| 160 |
|
| 161 |
vec_bs_expected = (vector bool short){ 0, 0, 1, 1, 0, 0, 1, 1 }; |
| 162 |
|
| 163 |
vec_bs_result = vec_unpackl (vec_bc_arg); |
| 164 |
|
| 165 |
for (i = 0; i < 8; i++) { |
| 166 |
if (vec_bs_expected[i] != vec_bs_result[i]) |
| 167 |
#if DEBUG |
| 168 |
printf("ERROR: vec_unpackl(), vec_bs_expected[%d] = %d does not match vec_bs_result[%d] = %d\n", |
| 169 |
i, vec_bs_expected[i], i, vec_bs_result[i]); |
| 170 |
#else |
| 171 |
abort(); |
| 172 |
#endif |
| 173 |
} |
| 174 |
|
| 175 |
|
| 176 |
vec_sc_arg = (vector signed char){ 0, 1, 2, 3, 4, 5, 6, 7, |
| 177 |
8, 9, 10, 11, 12, 13, 14, 15 }; |
| 178 |
|
| 179 |
vec_ss_expected = (vector signed short){ 0, 1, 2, 3, 4, 5, 6, 7 }; |
| 180 |
|
| 181 |
vec_ss_result = vec_unpackh (vec_sc_arg); |
| 182 |
|
| 183 |
for (i = 0; i < 8; i++) { |
| 184 |
if (vec_ss_expected[i] != vec_ss_result[i]) |
| 185 |
#if DEBUG |
| 186 |
printf("ERROR: vec_unpackh(), vec_ss_expected[%d] = %d does not match vec_ss_result[%d] = %d\n", |
| 187 |
i, vec_ss_expected[i], i, vec_ss_result[i]); |
| 188 |
#else |
| 189 |
abort(); |
| 190 |
#endif |
| 191 |
} |
| 192 |
|
| 193 |
vec_ss_expected = (vector signed short){ 8, 9, 10, 11, 12, 13, 14, 15 }; |
| 194 |
|
| 195 |
vec_ss_result = vec_unpackl (vec_sc_arg); |
| 196 |
|
| 197 |
for (i = 0; i < 8; i++) { |
| 198 |
if (vec_ss_expected[i] != vec_ss_result[i]) |
| 199 |
#if DEBUG |
| 200 |
printf("ERROR: vec_unpackl(), vec_ss_expected[%d] = %d does not match vec_ss_result[%d] = %d\n", |
| 201 |
i, vec_ss_expected[i], i, vec_ss_result[i]); |
| 202 |
#else |
| 203 |
abort(); |
| 204 |
#endif |
| 205 |
} |
| 206 |
|
| 207 |
return 0; |
| 208 |
} |