1 /* { dg-do run { target { powerpc*-*-* && p9vector_hw } } } */
2 /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */
3 /* { dg-require-effective-target powerpc_p9vector_ok } */
4 /* { dg-options "-mcpu=power9 -O2" } */
18 int result_wrong_ull (vector
unsigned long long vec_expected
,
19 vector
unsigned long long vec_actual
)
23 for (i
= 0; i
< 2; i
++)
24 if (vec_expected
[i
] != vec_actual
[i
])
30 int result_wrong_uc (vector
unsigned char vec_expected
,
31 vector
unsigned char vec_actual
)
35 for (i
= 0; i
< 16; i
++)
36 if (vec_expected
[i
] != vec_actual
[i
])
43 void print_ull (vector
unsigned long long vec_expected
,
44 vector
unsigned long long vec_actual
)
48 printf("expected unsigned long long data\n");
49 for (i
= 0; i
< 2; i
++)
50 printf(" %lld,", vec_expected
[i
]);
52 printf("\nactual signed char data\n");
53 for (i
= 0; i
< 2; i
++)
54 printf(" %lld,", vec_actual
[i
]);
58 void print_uc (vector
unsigned char vec_expected
,
59 vector
unsigned char vec_actual
)
63 printf("expected unsigned char data\n");
64 for (i
= 0; i
< 16; i
++)
65 printf(" %d,", vec_expected
[i
]);
67 printf("\nactual unsigned char data\n");
68 for (i
= 0; i
< 16; i
++)
69 printf(" %d,", vec_actual
[i
]);
75 vector
unsigned long long
76 vext (vector
unsigned char *vc
)
78 return vextract_si_vchar (*vc
, 5);
84 vector
signed int vsi_arg
;
85 vector
unsigned int vui_arg
;
86 vector
unsigned char vec_uc_arg
, vec_uc_result
, vec_uc_expected
;
87 vector
unsigned long long vec_ull_result
, vec_ull_expected
;
88 unsigned long long ull_result
, ull_expected
;
90 vec_uc_arg
= (vector
unsigned char){1, 2, 3, 4,
95 vsi_arg
= (vector
signed int){0xA, 0xB, 0xC, 0xD};
97 vec_uc_expected
= (vector
unsigned char){0xC, 0, 0, 0,
101 /* Test vec_insert4b() */
102 /* Insert into char 0 location */
103 vec_uc_result
= vec_insert4b (vsi_arg
, vec_uc_arg
, 0);
105 if (result_wrong_uc(vec_uc_expected
, vec_uc_result
))
108 printf("Error: vec_insert4b pos 0, result does not match expected result\n");
109 print_uc (vec_uc_expected
, vec_uc_result
);
115 /* insert into char 4 location */
116 vec_uc_expected
= (vector
unsigned char){1, 2, 3, 4,
120 vui_arg
= (vector
unsigned int){0x4, 0x3, 0x2, 0x1};
122 vec_uc_result
= vec_insert4b (vui_arg
, vec_uc_arg
, 4);
124 if (result_wrong_uc(vec_uc_expected
, vec_uc_result
))
127 printf("Error: vec_insert4b pos 4, result does not match expected result\n");
128 print_uc (vec_uc_expected
, vec_uc_result
);
134 /* Test vec_extract4b() */
135 /* Extract 4b, from char 0 location */
136 vec_uc_arg
= (vector
unsigned char){10, 0, 0, 0,
141 vec_ull_expected
= (vector
unsigned long long){0, 10};
142 vec_ull_result
= vec_extract4b(vec_uc_arg
, 0);
144 if (result_wrong_ull(vec_ull_expected
, vec_ull_result
))
147 printf("Error: vec_extract4b pos 0, result does not match expected result\n");
148 print_ull (vec_ull_expected
, vec_ull_result
);
154 /* Extract 4b, from char 12 location */
155 vec_uc_arg
= (vector
unsigned char){10, 0, 0, 0,
160 vec_ull_expected
= (vector
unsigned long long){0, 40};
161 vec_ull_result
= vec_extract4b(vec_uc_arg
, 12);
163 if (result_wrong_ull(vec_ull_expected
, vec_ull_result
))
166 printf("Error: vec_extract4b pos 12, result does not match expected result\n");
167 print_ull (vec_ull_expected
, vec_ull_result
);