@samitouri / QOSamiQemu / commits / dde6dc062a

tests/tcg/hexagon: add HVX tests for vabsdiff

Cover the four vabsdiff variants. The expected value is computed in int64_t to avoid overflowing the source element type. Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> Link: https://lore.kernel.org/qemu-devel/20260807152241.1576334-8-brian.cain@oss.qualcomm.com Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>

Brian Cain committed Aug 7, 2026 at 08:22 UTC dde6dc062adbae1c1a1928a87cc425c310339c2b
1 file changed +33
tests/tcg/hexagon/hvx_misc.c
+33
@@ -317,6 +317,34 @@ TEST_VEC_OP2(vand, vand, , d, 8, &)
317 TEST_VEC_OP2(vor, vor, , d, 8, |)
318 TEST_VEC_OP1(vnot, vnot, , d, 8, ~)
319
320 +#define TEST_VEC_ABSDIFF(NAME, INTRINSIC, SRC_FIELD, DST_FIELD, \
321 + CHECK_FIELD, FIELDSZ) \
322 +static inline void test_##NAME(void) \
323 +{ \
324 + HVX_Vector v0; \
325 + HVX_Vector v1; \
326 + HVX_Vector vres; \
327 + for (int i = 0; i < BUFSIZE; i++) { \
328 + memcpy(&v0, &buffer0[i], sizeof(MMVector)); \
329 + memcpy(&v1, &buffer1[i], sizeof(MMVector)); \
330 + vres = INTRINSIC(v0, v1); \
331 + memcpy(&output[i], &vres, sizeof(MMVector)); \
332 + } \
333 + for (int i = 0; i < BUFSIZE; i++) { \
334 + for (int j = 0; j < MAX_VEC_SIZE_BYTES / FIELDSZ; j++) { \
335 + int64_t diff = (int64_t)buffer0[i].SRC_FIELD[j] - \
336 + (int64_t)buffer1[i].SRC_FIELD[j]; \
337 + expect[i].DST_FIELD[j] = diff < 0 ? -diff : diff; \
338 + } \
339 + } \
340 + check_output_##CHECK_FIELD(__LINE__, BUFSIZE); \
341 +}
342 +
343 +TEST_VEC_ABSDIFF(vabsdiffub, Q6_Vub_vabsdiff_VubVub, ub, ub, b, 1)
344 +TEST_VEC_ABSDIFF(vabsdiffuh, Q6_Vuh_vabsdiff_VuhVuh, uh, uh, h, 2)
345 +TEST_VEC_ABSDIFF(vabsdiffh, Q6_Vuh_vabsdiff_VhVh, h, uh, h, 2)
346 +TEST_VEC_ABSDIFF(vabsdiffw, Q6_Vuw_vabsdiff_VwVw, w, uw, w, 4)
347 +
348 TEST_PRED_OP2(pred_or, or, |, "")
349 TEST_PRED_OP2(pred_or_n, or, |, "!")
350 TEST_PRED_OP2(pred_and, and, &, "")
@@ -575,6 +603,11 @@ int main()
603 test_vsubuwsat_dv();
604 test_vsubwsat();
605
606 + test_vabsdiffub();
607 + test_vabsdiffuh();
608 + test_vabsdiffh();
609 + test_vabsdiffw();
610 +
611 test_load_tmp_predicated();
612 test_load_cur_predicated();
613