From de7711971b41d9d2c0ff604cd0eff3fa526530f5 Mon Sep 17 00:00:00 2001 From: Jiajie Chen Date: Thu, 14 Dec 2023 13:13:04 +0800 Subject: [PATCH] Add vext2xv testcases, try to fix xvshuf --- code/gen_tb.py | 3 ++- code/vext2xv_d_b.cpp | 9 +++++++++ code/vext2xv_d_h.cpp | 9 +++++++++ code/vext2xv_du_bu.cpp | 9 +++++++++ code/vext2xv_du_hu.cpp | 9 +++++++++ code/vext2xv_w_b.cpp | 9 +++++++++ code/vext2xv_wu_bu.cpp | 9 +++++++++ code/vshuf_h.h | 2 +- code/xvshuf_b.h | 10 ++++++---- code/xvshuf_h.h | 10 ++++++---- 10 files changed, 69 insertions(+), 10 deletions(-) create mode 100644 code/vext2xv_d_b.cpp create mode 100644 code/vext2xv_d_h.cpp create mode 100644 code/vext2xv_du_bu.cpp create mode 100644 code/vext2xv_du_hu.cpp create mode 100644 code/vext2xv_w_b.cpp create mode 100644 code/vext2xv_wu_bu.cpp diff --git a/code/gen_tb.py b/code/gen_tb.py index b1f501d0..d572749d 100644 --- a/code/gen_tb.py +++ b/code/gen_tb.py @@ -5,6 +5,7 @@ widths_fp = ["s", "d"] widths_all = ["b", "bu", "h", "hu", "w", "wu", "d", "du"] widths_vexth = ["h_b", "hu_bu", "w_h", "wu_hu", "d_w", "du_wu", "q_d", "qu_du"] +widths_vext2xv = ["h_b", "hu_bu", "w_b", "wu_bu", "w_h", "wu_hu", "d_b", "du_bu", "d_h", "du_hu", "d_w", "du_wu"] widths_vsllwil = ["h_b", "hu_bu", "w_h", "wu_hu", "d_w", "du_wu"] widths_vsrln = ["b_h", "h_w", "w_d"] widths_vssrln = ["b_h", "bu_h", "h_w", "hu_w", "w_d", "wu_d"] @@ -67,7 +68,7 @@ "v128 a, v128 b, int imm", [0, 3, 7, 15, 16, 32, 64, 128, 255], ), - "vext2xv": (widths_vsllwil, "v128 a"), + "vext2xv": (widths_vext2xv, "v128 a"), "vfrstp": (widths_vfrstp, "v128 a, v128 b, v128 c"), "vfrstpi": (widths_vfrstp, "v128 a, v128 b, int imm", [0, 4, 31]), "vhaddw": (widths_vexth, "v128 a, v128 b"), diff --git a/code/vext2xv_d_b.cpp b/code/vext2xv_d_b.cpp new file mode 100644 index 00000000..5ad738f8 --- /dev/null +++ b/code/vext2xv_d_b.cpp @@ -0,0 +1,9 @@ +#include "common.h" + +v256 vext2xv_d_b(v256 a) { + v256 dst; +#include "vext2xv_d_b.h" + return dst; +} + +void test() { XFUZZ1(vext2xv_d_b); } diff --git a/code/vext2xv_d_h.cpp b/code/vext2xv_d_h.cpp new file mode 100644 index 00000000..6b28ec00 --- /dev/null +++ b/code/vext2xv_d_h.cpp @@ -0,0 +1,9 @@ +#include "common.h" + +v256 vext2xv_d_h(v256 a) { + v256 dst; +#include "vext2xv_d_h.h" + return dst; +} + +void test() { XFUZZ1(vext2xv_d_h); } diff --git a/code/vext2xv_du_bu.cpp b/code/vext2xv_du_bu.cpp new file mode 100644 index 00000000..001f595e --- /dev/null +++ b/code/vext2xv_du_bu.cpp @@ -0,0 +1,9 @@ +#include "common.h" + +v256 vext2xv_du_bu(v256 a) { + v256 dst; +#include "vext2xv_du_bu.h" + return dst; +} + +void test() { XFUZZ1(vext2xv_du_bu); } diff --git a/code/vext2xv_du_hu.cpp b/code/vext2xv_du_hu.cpp new file mode 100644 index 00000000..2b7b42ab --- /dev/null +++ b/code/vext2xv_du_hu.cpp @@ -0,0 +1,9 @@ +#include "common.h" + +v256 vext2xv_du_hu(v256 a) { + v256 dst; +#include "vext2xv_du_hu.h" + return dst; +} + +void test() { XFUZZ1(vext2xv_du_hu); } diff --git a/code/vext2xv_w_b.cpp b/code/vext2xv_w_b.cpp new file mode 100644 index 00000000..45a76a78 --- /dev/null +++ b/code/vext2xv_w_b.cpp @@ -0,0 +1,9 @@ +#include "common.h" + +v256 vext2xv_w_b(v256 a) { + v256 dst; +#include "vext2xv_w_b.h" + return dst; +} + +void test() { XFUZZ1(vext2xv_w_b); } diff --git a/code/vext2xv_wu_bu.cpp b/code/vext2xv_wu_bu.cpp new file mode 100644 index 00000000..7dd67937 --- /dev/null +++ b/code/vext2xv_wu_bu.cpp @@ -0,0 +1,9 @@ +#include "common.h" + +v256 vext2xv_wu_bu(v256 a) { + v256 dst; +#include "vext2xv_wu_bu.h" + return dst; +} + +void test() { XFUZZ1(vext2xv_wu_bu); } diff --git a/code/vshuf_h.h b/code/vshuf_h.h index 9b6d7dc5..bea8c20e 100644 --- a/code/vshuf_h.h +++ b/code/vshuf_h.h @@ -7,4 +7,4 @@ for (int i = 0; i < 8; i++) { } else { dst.half[i] = b.half[a.half[i] % 8]; } -} \ No newline at end of file +} diff --git a/code/xvshuf_b.h b/code/xvshuf_b.h index ed70425d..7befd03c 100644 --- a/code/xvshuf_b.h +++ b/code/xvshuf_b.h @@ -1,7 +1,9 @@ for (int i = 0; i < 32; i++) { - if ((c.byte[i] % 64) < 32) { - dst.byte[i] = b.byte[c.byte[i] % 32]; + if (c.byte[i] >= 64) { + dst.byte[i] = 0; + } else if ((c.byte[i] % 32) < 16) { + dst.byte[i] = b.byte[(c.byte[i] % 32) + ((i >= 16) ? 16 : 0)]; } else { - dst.byte[i] = a.byte[c.byte[i] % 32]; + dst.byte[i] = a.byte[(c.byte[i] % 32) + ((i >= 16) ? 0 : -16)]; } -} \ No newline at end of file +} diff --git a/code/xvshuf_h.h b/code/xvshuf_h.h index 0a337092..88c5ab55 100644 --- a/code/xvshuf_h.h +++ b/code/xvshuf_h.h @@ -1,7 +1,9 @@ for (int i = 0; i < 16; i++) { - if ((a.half[i] % 32) < 16) { - dst.half[i] = c.half[a.half[i] % 16]; + if ((c.half[i] % 256) >= 64) { + dst.half[i] = 0; + } else if ((c.half[i] % 16) < 8) { + dst.half[i] = b.half[(c.half[i] % 16) + ((i >= 8) ? 8 : 0)]; } else { - dst.half[i] = b.half[a.half[i] % 16]; + dst.half[i] = a.half[(c.half[i] % 16) + ((i >= 8) ? 0 : -8)]; } -} \ No newline at end of file +}