From 4e4404f083fff6caa82e822dbef1eb6ee337d623 Mon Sep 17 00:00:00 2001 From: Jiajie Chen Date: Tue, 12 Dec 2023 14:57:14 +0800 Subject: [PATCH] Addd vaddwod --- README.md | 4 -- code/gen_impl.py | 78 ++++++++++++++++++++++++++++++++----- code/gen_tb.py | 48 ++++++++++++++++------- code/vabsd_b.h | 3 +- code/vabsd_bu.h | 3 +- code/vabsd_d.h | 4 +- code/vabsd_du.h | 4 +- code/vabsd_h.h | 3 +- code/vabsd_hu.h | 3 +- code/vabsd_w.h | 3 +- code/vabsd_wu.h | 3 +- code/vadda_d.h | 1 - code/vadda_h.cpp | 1 - code/vadda_h.h | 1 - code/vadda_w.cpp | 1 - code/vaddwev_d_w.h | 2 +- code/vaddwev_d_wu.h | 2 +- code/vaddwev_d_wu_w.h | 2 +- code/vaddwev_h_b.h | 4 +- code/vaddwev_h_bu.h | 4 +- code/vaddwev_h_bu_b.h | 2 +- code/vaddwev_q_d.h | 4 +- code/vaddwev_q_du.h | 4 +- code/vaddwev_q_du_d.h | 4 +- code/vaddwev_w_h.h | 2 +- code/vaddwev_w_hu.h | 2 +- code/vaddwev_w_hu_h.h | 2 +- code/vaddwod_d_w.cpp | 9 +++++ code/vaddwod_d_w.h | 3 ++ code/vaddwod_d_wu.cpp | 9 +++++ code/vaddwod_d_wu.h | 3 ++ code/vaddwod_d_wu_w.cpp | 9 +++++ code/vaddwod_d_wu_w.h | 3 ++ code/vaddwod_h_b.cpp | 9 +++++ code/vaddwod_h_b.h | 3 ++ code/vaddwod_h_bu.cpp | 9 +++++ code/vaddwod_h_bu.h | 3 ++ code/vaddwod_h_bu_b.cpp | 9 +++++ code/vaddwod_h_bu_b.h | 3 ++ code/vaddwod_q_d.cpp | 9 +++++ code/vaddwod_q_d.h | 3 ++ code/vaddwod_q_du.cpp | 9 +++++ code/vaddwod_q_du.h | 3 ++ code/vaddwod_q_du_d.cpp | 9 +++++ code/vaddwod_q_du_d.h | 3 ++ code/vaddwod_w_h.cpp | 9 +++++ code/vaddwod_w_h.h | 3 ++ code/vaddwod_w_hu.cpp | 9 +++++ code/vaddwod_w_hu.h | 3 ++ code/vaddwod_w_hu_h.cpp | 9 +++++ code/vaddwod_w_hu_h.h | 3 ++ code/vand_v.cpp | 4 +- code/vandi_b.h | 4 +- code/vandn_v.cpp | 4 +- code/vavg_b.cpp | 4 +- code/vavg_b.h | 5 ++- code/vavg_bu.cpp | 4 +- code/vavg_bu.h | 5 ++- code/vavg_d.cpp | 4 +- code/vavg_d.h | 5 ++- code/vavg_du.cpp | 4 +- code/vavg_du.h | 5 ++- code/vavg_h.cpp | 4 +- code/vavg_h.h | 5 ++- code/vavg_hu.cpp | 4 +- code/vavg_hu.h | 5 ++- code/vavg_w.cpp | 4 +- code/vavg_w.h | 5 ++- code/vavg_wu.cpp | 4 +- code/vavg_wu.h | 5 ++- code/vavgr_b.cpp | 4 +- code/vavgr_b.h | 5 ++- code/vavgr_bu.cpp | 4 +- code/vavgr_bu.h | 5 ++- code/vavgr_d.cpp | 4 +- code/vavgr_d.h | 5 ++- code/vavgr_du.cpp | 4 +- code/vavgr_du.h | 5 ++- code/vavgr_h.cpp | 4 +- code/vavgr_h.h | 5 ++- code/vavgr_hu.cpp | 4 +- code/vavgr_hu.h | 5 ++- code/vavgr_w.cpp | 4 +- code/vavgr_w.h | 5 ++- code/vavgr_wu.cpp | 4 +- code/vavgr_wu.h | 5 ++- code/vbitsel_v.cpp | 4 +- code/vldrepl_b.h | 4 +- code/vldrepl_d.h | 4 +- code/vldrepl_h.h | 4 +- code/vldrepl_w.h | 4 +- code/vshuf_b.cpp | 4 +- code/vshuf_h.cpp | 4 +- code/vshuf_w.cpp | 4 +- docs/lsx_integer/vaddsub.md | 13 +++++++ main.py | 19 +++++++++ 96 files changed, 396 insertions(+), 162 deletions(-) create mode 100644 code/vaddwod_d_w.cpp create mode 100644 code/vaddwod_d_w.h create mode 100644 code/vaddwod_d_wu.cpp create mode 100644 code/vaddwod_d_wu.h create mode 100644 code/vaddwod_d_wu_w.cpp create mode 100644 code/vaddwod_d_wu_w.h create mode 100644 code/vaddwod_h_b.cpp create mode 100644 code/vaddwod_h_b.h create mode 100644 code/vaddwod_h_bu.cpp create mode 100644 code/vaddwod_h_bu.h create mode 100644 code/vaddwod_h_bu_b.cpp create mode 100644 code/vaddwod_h_bu_b.h create mode 100644 code/vaddwod_q_d.cpp create mode 100644 code/vaddwod_q_d.h create mode 100644 code/vaddwod_q_du.cpp create mode 100644 code/vaddwod_q_du.h create mode 100644 code/vaddwod_q_du_d.cpp create mode 100644 code/vaddwod_q_du_d.h create mode 100644 code/vaddwod_w_h.cpp create mode 100644 code/vaddwod_w_h.h create mode 100644 code/vaddwod_w_hu.cpp create mode 100644 code/vaddwod_w_hu.h create mode 100644 code/vaddwod_w_hu_h.cpp create mode 100644 code/vaddwod_w_hu_h.h diff --git a/README.md b/README.md index 2021320e..53ee95d8 100644 --- a/README.md +++ b/README.md @@ -30,18 +30,14 @@ Vector Subtract Vector Subtract with Width Extension -### vaddwod.h.b/w.h/d.w/q.d ### vsubwod.h.b/w.h/d.w/q.d ### vsubwev.h.bu/w.hu/d.wu/q.du Vector Subtract with Width Extension Unsigned -### vaddwod.h.bu/w.hu/d.wu/q.du ### vsubwod.h.bu/w.hu/d.wu/q.du -### vaddwod.h.bu.b/w.hu.h/q.wu.w/q.du.d - ### vsadd.b/h/w/d Vector Saturated Add diff --git a/code/gen_impl.py b/code/gen_impl.py index 6ec7167b..b16b27dd 100644 --- a/code/gen_impl.py +++ b/code/gen_impl.py @@ -1,4 +1,4 @@ -widths_all = ["b", "bu", "h", "hu", "w", "wu", "d", "du"] +import os widths = { "b": 8, @@ -10,6 +10,18 @@ "d": 64, "du": 64, "q": 128, + "qu": 128, +} + +double_widths = { + "b": "h", + "bu": "h", + "h": "w", + "hu": "w", + "w": "d", + "wu": "d", + "d": "q", + "du": "q", } members = { @@ -21,20 +33,66 @@ "wu": "word", "d": "dword", "du": "dword", + "q": "qword", + "qu": "qword", } -for width in widths_all: +for width in ["b", "bu", "h", "hu", "w", "wu", "d", "du"]: + w = widths[width] + m = members[width] + if "u" in width: + sign = "u" + else: + sign = "s" + with open(f"vavg_{width}.h", "w") as f: + print(f"for (int i = 0;i < {128 // w};i++) {{", file=f) + print( + f" dst.{m}[i] = (({sign}{w})a.{m}[i] >> 1) + (({sign}{w})b.{m}[i] >> 1) + (a.{m}[i] & b.{m}[i] & 1);", + file=f, + ) + print(f"}}", file=f) + with open(f"vavgr_{width}.h", "w") as f: + print(f"for (int i = 0;i < {128 // w};i++) {{", file=f) + print( + f" dst.{m}[i] = (({sign}{w})a.{m}[i] >> 1) + (({sign}{w})b.{m}[i] >> 1) + ((a.{m}[i] | b.{m}[i]) & 1);", + file=f, + ) + print(f"}}", file=f) + +for width in ["b", "bu", "h", "hu", "w", "wu", "d", "du"]: + double_width = double_widths[width] w = widths[width] m = members[width] + double_w = widths[double_width] + double_m = members[double_width] if "u" in width: sign = "u" else: sign = "s" - with open(f"vavg_{width}.h", 'w') as f: - print(f'for (int i = 0;i < {128 // w};i++) {{', file=f) - print(f' dst.{m}[i] = (({sign}{w})a.{m}[i] >> 1) + (({sign}{w})b.{m}[i] >> 1) + (a.{m}[i] & b.{m}[i] & 1);', file=f) - print(f'}}', file=f) - with open(f"vavgr_{width}.h", 'w') as f: - print(f'for (int i = 0;i < {128 // w};i++) {{', file=f) - print(f' dst.{m}[i] = (({sign}{w})a.{m}[i] >> 1) + (({sign}{w})b.{m}[i] >> 1) + ((a.{m}[i] | b.{m}[i]) & 1);', file=f) - print(f'}}', file=f) \ No newline at end of file + for signed2 in [False, True]: + if "u" not in width and not signed2: + continue + if "u" in width and signed2: + suffix = f"_{width[:-1]}" + else: + suffix = "" + if signed2: + sign2 = "s" + else: + sign2 = "u" + with open(f"vaddwev_{double_width}_{width}{suffix}.h", "w") as f: + print(f"for (int i = 0;i < {128 // double_w};i++) {{", file=f) + print( + f" dst.{double_m}[i] = ({sign}{double_w})({sign}{w})a.{m}[2 * i] + ({sign2}{double_w})({sign2}{w})b.{m}[2 * i];", + file=f, + ) + print(f"}}", file=f) + with open(f"vaddwod_{double_width}_{width}{suffix}.h", "w") as f: + print(f"for (int i = 0;i < {128 // double_w};i++) {{", file=f) + print( + f" dst.{double_m}[i] = ({sign}{double_w})({sign}{w})a.{m}[2 * i + 1] + ({sign2}{double_w})({sign2}{w})b.{m}[2 * i + 1];", + file=f, + ) + print(f"}}", file=f) + +os.system("clang-format -i *.cpp *.h") \ No newline at end of file diff --git a/code/gen_tb.py b/code/gen_tb.py index 7b5a912a..9c35978c 100644 --- a/code/gen_tb.py +++ b/code/gen_tb.py @@ -1,8 +1,26 @@ +import os + widths_all = ["b", "bu", "h", "hu", "w", "wu", "d", "du"] +widths_vaddw = [ + "h_b", + "h_bu", + "h_bu_b", + "w_h", + "w_hu", + "w_hu_h", + "d_w", + "d_wu", + "d_wu_w", + "q_d", + "q_du", + "q_du_d", +] tb = { "vavg": (widths_all, "v128 a, v128 b"), - "vavgr": (widths_all, "v128 a, v128 b") + "vavgr": (widths_all, "v128 a, v128 b"), + "vaddwev": (widths_vaddw, "v128 a, v128 b"), + "vaddwod": (widths_vaddw, "v128 a, v128 b"), } for name in tb: @@ -14,20 +32,22 @@ inst_name = name + "_" + width fuzz_args = 0 - for arg in args.split(', '): - if 'v128' in arg: + for arg in args.split(", "): + if "v128" in arg: fuzz_args += 1 - print(f'Saving {inst_name}.cpp') - with open(f'{inst_name}.cpp', 'w') as f: + print(f"Saving {inst_name}.cpp") + with open(f"{inst_name}.cpp", "w") as f: print('#include "common.h"', file=f) - print('', file=f) - print(f'v128 {inst_name}({args}) {{', file=f) - print(' v128 dst;', file=f) + print("", file=f) + print(f"v128 {inst_name}({args}) {{", file=f) + print(" v128 dst;", file=f) print(f'#include "{inst_name}.h"', file=f) - print(' return dst;', file=f) - print('}', file=f) - print('', file=f) - print('void test() {', file=f) - print(f' FUZZ{fuzz_args}({inst_name});', file=f) - print('}', file=f) \ No newline at end of file + print(" return dst;", file=f) + print("}", file=f) + print("", file=f) + print("void test() {", file=f) + print(f" FUZZ{fuzz_args}({inst_name});", file=f) + print("}", file=f) + +os.system("clang-format -i *.cpp *.h") \ No newline at end of file diff --git a/code/vabsd_b.h b/code/vabsd_b.h index 5ff7a07a..cae05826 100644 --- a/code/vabsd_b.h +++ b/code/vabsd_b.h @@ -1,3 +1,4 @@ for (int i = 0; i < 16; i++) { - dst.byte[i] = ((s8)a.byte[i] > (s8)b.byte[i]) ? (a.byte[i] - b.byte[i]) : (b.byte[i] - a.byte[i]); + dst.byte[i] = ((s8)a.byte[i] > (s8)b.byte[i]) ? (a.byte[i] - b.byte[i]) + : (b.byte[i] - a.byte[i]); } diff --git a/code/vabsd_bu.h b/code/vabsd_bu.h index a6284af3..ceb85be7 100644 --- a/code/vabsd_bu.h +++ b/code/vabsd_bu.h @@ -1,3 +1,4 @@ for (int i = 0; i < 16; i++) { - dst.byte[i] = ((u8)a.byte[i] > (u8)b.byte[i]) ? (a.byte[i] - b.byte[i]) : (b.byte[i] - a.byte[i]); + dst.byte[i] = ((u8)a.byte[i] > (u8)b.byte[i]) ? (a.byte[i] - b.byte[i]) + : (b.byte[i] - a.byte[i]); } diff --git a/code/vabsd_d.h b/code/vabsd_d.h index 2aa17fb0..d3d199c1 100644 --- a/code/vabsd_d.h +++ b/code/vabsd_d.h @@ -1,3 +1,5 @@ for (int i = 0; i < 2; i++) { - dst.dword[i] = ((s64)a.dword[i] > (s64)b.dword[i]) ? (a.dword[i] - b.dword[i]) : (b.dword[i] - a.dword[i]); + dst.dword[i] = ((s64)a.dword[i] > (s64)b.dword[i]) + ? (a.dword[i] - b.dword[i]) + : (b.dword[i] - a.dword[i]); } diff --git a/code/vabsd_du.h b/code/vabsd_du.h index eb27f455..56292893 100644 --- a/code/vabsd_du.h +++ b/code/vabsd_du.h @@ -1,3 +1,5 @@ for (int i = 0; i < 2; i++) { - dst.dword[i] = ((u64)a.dword[i] > (u64)b.dword[i]) ? (a.dword[i] - b.dword[i]) : (b.dword[i] - a.dword[i]); + dst.dword[i] = ((u64)a.dword[i] > (u64)b.dword[i]) + ? (a.dword[i] - b.dword[i]) + : (b.dword[i] - a.dword[i]); } diff --git a/code/vabsd_h.h b/code/vabsd_h.h index 63069214..26ff37cb 100644 --- a/code/vabsd_h.h +++ b/code/vabsd_h.h @@ -1,3 +1,4 @@ for (int i = 0; i < 8; i++) { - dst.half[i] = ((s16)a.half[i] > (s16)b.half[i]) ? (a.half[i] - b.half[i]) : (b.half[i] - a.half[i]); + dst.half[i] = ((s16)a.half[i] > (s16)b.half[i]) ? (a.half[i] - b.half[i]) + : (b.half[i] - a.half[i]); } diff --git a/code/vabsd_hu.h b/code/vabsd_hu.h index bd167630..8cf1a79e 100644 --- a/code/vabsd_hu.h +++ b/code/vabsd_hu.h @@ -1,3 +1,4 @@ for (int i = 0; i < 8; i++) { - dst.half[i] = ((u16)a.half[i] > (u16)b.half[i]) ? (a.half[i] - b.half[i]) : (b.half[i] - a.half[i]); + dst.half[i] = ((u16)a.half[i] > (u16)b.half[i]) ? (a.half[i] - b.half[i]) + : (b.half[i] - a.half[i]); } diff --git a/code/vabsd_w.h b/code/vabsd_w.h index e62f5089..26a3c044 100644 --- a/code/vabsd_w.h +++ b/code/vabsd_w.h @@ -1,3 +1,4 @@ for (int i = 0; i < 4; i++) { - dst.word[i] = ((s32)a.word[i] > (s32)b.word[i]) ? (a.word[i] - b.word[i]) : (b.word[i] - a.word[i]); + dst.word[i] = ((s32)a.word[i] > (s32)b.word[i]) ? (a.word[i] - b.word[i]) + : (b.word[i] - a.word[i]); } diff --git a/code/vabsd_wu.h b/code/vabsd_wu.h index 880b8add..1585e5f0 100644 --- a/code/vabsd_wu.h +++ b/code/vabsd_wu.h @@ -1,3 +1,4 @@ for (int i = 0; i < 4; i++) { - dst.word[i] = ((u32)a.word[i] > (u32)b.word[i]) ? (a.word[i] - b.word[i]) : (b.word[i] - a.word[i]); + dst.word[i] = ((u32)a.word[i] > (u32)b.word[i]) ? (a.word[i] - b.word[i]) + : (b.word[i] - a.word[i]); } diff --git a/code/vadda_d.h b/code/vadda_d.h index 72e48397..6ffc06cd 100644 --- a/code/vadda_d.h +++ b/code/vadda_d.h @@ -1,4 +1,3 @@ for (int i = 0; i < 2; i++) { dst.dword[i] = abs((s64)a.dword[i]) + abs((s64)b.dword[i]); } - diff --git a/code/vadda_h.cpp b/code/vadda_h.cpp index d9216b91..4758de78 100644 --- a/code/vadda_h.cpp +++ b/code/vadda_h.cpp @@ -7,4 +7,3 @@ v128 vadda_h(v128 a, v128 b) { } void test() { FUZZ2(vadda_h); } - diff --git a/code/vadda_h.h b/code/vadda_h.h index 6e6f3762..c7c4dd18 100644 --- a/code/vadda_h.h +++ b/code/vadda_h.h @@ -1,4 +1,3 @@ for (int i = 0; i < 8; i++) { dst.half[i] = abs((s16)a.half[i]) + abs((s16)b.half[i]); } - diff --git a/code/vadda_w.cpp b/code/vadda_w.cpp index 3e7ad2c2..36eeca36 100644 --- a/code/vadda_w.cpp +++ b/code/vadda_w.cpp @@ -7,4 +7,3 @@ v128 vadda_w(v128 a, v128 b) { } void test() { FUZZ2(vadda_w); } - diff --git a/code/vaddwev_d_w.h b/code/vaddwev_d_w.h index 2d7ea9c7..37ea2f26 100644 --- a/code/vaddwev_d_w.h +++ b/code/vaddwev_d_w.h @@ -1,3 +1,3 @@ -for (int i = 0;i < 2;i++) { +for (int i = 0; i < 2; i++) { dst.dword[i] = (s64)(s32)a.word[2 * i] + (s64)(s32)b.word[2 * i]; } diff --git a/code/vaddwev_d_wu.h b/code/vaddwev_d_wu.h index 7957d286..6610963d 100644 --- a/code/vaddwev_d_wu.h +++ b/code/vaddwev_d_wu.h @@ -1,3 +1,3 @@ -for (int i = 0;i < 2;i++) { +for (int i = 0; i < 2; i++) { dst.dword[i] = (u64)(u32)a.word[2 * i] + (u64)(u32)b.word[2 * i]; } diff --git a/code/vaddwev_d_wu_w.h b/code/vaddwev_d_wu_w.h index 5359ea65..af28ff89 100644 --- a/code/vaddwev_d_wu_w.h +++ b/code/vaddwev_d_wu_w.h @@ -1,3 +1,3 @@ -for (int i = 0;i < 2;i++) { +for (int i = 0; i < 2; i++) { dst.dword[i] = (u64)(u32)a.word[2 * i] + (s64)(s32)b.word[2 * i]; } diff --git a/code/vaddwev_h_b.h b/code/vaddwev_h_b.h index 12cb1d11..fecff802 100644 --- a/code/vaddwev_h_b.h +++ b/code/vaddwev_h_b.h @@ -1,3 +1,3 @@ -for (int i = 0;i < 8;i++) { +for (int i = 0; i < 8; i++) { dst.half[i] = (s16)(s8)a.byte[2 * i] + (s16)(s8)b.byte[2 * i]; -} \ No newline at end of file +} diff --git a/code/vaddwev_h_bu.h b/code/vaddwev_h_bu.h index eacfceea..5515b3dd 100644 --- a/code/vaddwev_h_bu.h +++ b/code/vaddwev_h_bu.h @@ -1,3 +1,3 @@ -for (int i = 0;i < 8;i++) { +for (int i = 0; i < 8; i++) { dst.half[i] = (u16)(u8)a.byte[2 * i] + (u16)(u8)b.byte[2 * i]; -} \ No newline at end of file +} diff --git a/code/vaddwev_h_bu_b.h b/code/vaddwev_h_bu_b.h index 3a46945b..a6021008 100644 --- a/code/vaddwev_h_bu_b.h +++ b/code/vaddwev_h_bu_b.h @@ -1,3 +1,3 @@ -for (int i = 0;i < 8;i++) { +for (int i = 0; i < 8; i++) { dst.half[i] = (u16)(u8)a.byte[2 * i] + (s16)(s8)b.byte[2 * i]; } diff --git a/code/vaddwev_q_d.h b/code/vaddwev_q_d.h index afdaf5c8..f5d154f3 100644 --- a/code/vaddwev_q_d.h +++ b/code/vaddwev_q_d.h @@ -1 +1,3 @@ -dst.qword[0] = (s128)(s64)a.dword[0] + (s128)(s64)b.dword[0]; +for (int i = 0; i < 1; i++) { + dst.qword[i] = (s128)(s64)a.dword[2 * i] + (s128)(s64)b.dword[2 * i]; +} diff --git a/code/vaddwev_q_du.h b/code/vaddwev_q_du.h index 0c7d6e4b..c8e6d9cc 100644 --- a/code/vaddwev_q_du.h +++ b/code/vaddwev_q_du.h @@ -1 +1,3 @@ -dst.qword[0] = (u128)(u64)a.dword[0] + (u128)(u64)b.dword[0]; +for (int i = 0; i < 1; i++) { + dst.qword[i] = (u128)(u64)a.dword[2 * i] + (u128)(u64)b.dword[2 * i]; +} diff --git a/code/vaddwev_q_du_d.h b/code/vaddwev_q_du_d.h index 00aa6ed4..65a03378 100644 --- a/code/vaddwev_q_du_d.h +++ b/code/vaddwev_q_du_d.h @@ -1 +1,3 @@ -dst.qword[0] = (u128)(u64)a.dword[0] + (s128)(s64)b.dword[0]; +for (int i = 0; i < 1; i++) { + dst.qword[i] = (u128)(u64)a.dword[2 * i] + (s128)(s64)b.dword[2 * i]; +} diff --git a/code/vaddwev_w_h.h b/code/vaddwev_w_h.h index a7e259f3..8c72acb3 100644 --- a/code/vaddwev_w_h.h +++ b/code/vaddwev_w_h.h @@ -1,3 +1,3 @@ -for (int i = 0;i < 4;i++) { +for (int i = 0; i < 4; i++) { dst.word[i] = (s32)(s16)a.half[2 * i] + (s32)(s16)b.half[2 * i]; } diff --git a/code/vaddwev_w_hu.h b/code/vaddwev_w_hu.h index 5a13d045..6d4d604f 100644 --- a/code/vaddwev_w_hu.h +++ b/code/vaddwev_w_hu.h @@ -1,3 +1,3 @@ -for (int i = 0;i < 4;i++) { +for (int i = 0; i < 4; i++) { dst.word[i] = (u32)(u16)a.half[2 * i] + (u32)(u16)b.half[2 * i]; } diff --git a/code/vaddwev_w_hu_h.h b/code/vaddwev_w_hu_h.h index 62b0421c..33d145c3 100644 --- a/code/vaddwev_w_hu_h.h +++ b/code/vaddwev_w_hu_h.h @@ -1,3 +1,3 @@ -for (int i = 0;i < 4;i++) { +for (int i = 0; i < 4; i++) { dst.word[i] = (u32)(u16)a.half[2 * i] + (s32)(s16)b.half[2 * i]; } diff --git a/code/vaddwod_d_w.cpp b/code/vaddwod_d_w.cpp new file mode 100644 index 00000000..d6b08751 --- /dev/null +++ b/code/vaddwod_d_w.cpp @@ -0,0 +1,9 @@ +#include "common.h" + +v128 vaddwod_d_w(v128 a, v128 b) { + v128 dst; +#include "vaddwod_d_w.h" + return dst; +} + +void test() { FUZZ2(vaddwod_d_w); } diff --git a/code/vaddwod_d_w.h b/code/vaddwod_d_w.h new file mode 100644 index 00000000..ad4515bb --- /dev/null +++ b/code/vaddwod_d_w.h @@ -0,0 +1,3 @@ +for (int i = 0; i < 2; i++) { + dst.dword[i] = (s64)(s32)a.word[2 * i + 1] + (s64)(s32)b.word[2 * i + 1]; +} diff --git a/code/vaddwod_d_wu.cpp b/code/vaddwod_d_wu.cpp new file mode 100644 index 00000000..4ea1f4ca --- /dev/null +++ b/code/vaddwod_d_wu.cpp @@ -0,0 +1,9 @@ +#include "common.h" + +v128 vaddwod_d_wu(v128 a, v128 b) { + v128 dst; +#include "vaddwod_d_wu.h" + return dst; +} + +void test() { FUZZ2(vaddwod_d_wu); } diff --git a/code/vaddwod_d_wu.h b/code/vaddwod_d_wu.h new file mode 100644 index 00000000..f35c8d1f --- /dev/null +++ b/code/vaddwod_d_wu.h @@ -0,0 +1,3 @@ +for (int i = 0; i < 2; i++) { + dst.dword[i] = (u64)(u32)a.word[2 * i + 1] + (u64)(u32)b.word[2 * i + 1]; +} diff --git a/code/vaddwod_d_wu_w.cpp b/code/vaddwod_d_wu_w.cpp new file mode 100644 index 00000000..af1f81f3 --- /dev/null +++ b/code/vaddwod_d_wu_w.cpp @@ -0,0 +1,9 @@ +#include "common.h" + +v128 vaddwod_d_wu_w(v128 a, v128 b) { + v128 dst; +#include "vaddwod_d_wu_w.h" + return dst; +} + +void test() { FUZZ2(vaddwod_d_wu_w); } diff --git a/code/vaddwod_d_wu_w.h b/code/vaddwod_d_wu_w.h new file mode 100644 index 00000000..647ae4a0 --- /dev/null +++ b/code/vaddwod_d_wu_w.h @@ -0,0 +1,3 @@ +for (int i = 0; i < 2; i++) { + dst.dword[i] = (u64)(u32)a.word[2 * i + 1] + (s64)(s32)b.word[2 * i + 1]; +} diff --git a/code/vaddwod_h_b.cpp b/code/vaddwod_h_b.cpp new file mode 100644 index 00000000..93de869e --- /dev/null +++ b/code/vaddwod_h_b.cpp @@ -0,0 +1,9 @@ +#include "common.h" + +v128 vaddwod_h_b(v128 a, v128 b) { + v128 dst; +#include "vaddwod_h_b.h" + return dst; +} + +void test() { FUZZ2(vaddwod_h_b); } diff --git a/code/vaddwod_h_b.h b/code/vaddwod_h_b.h new file mode 100644 index 00000000..99a4aeca --- /dev/null +++ b/code/vaddwod_h_b.h @@ -0,0 +1,3 @@ +for (int i = 0; i < 8; i++) { + dst.half[i] = (s16)(s8)a.byte[2 * i + 1] + (s16)(s8)b.byte[2 * i + 1]; +} diff --git a/code/vaddwod_h_bu.cpp b/code/vaddwod_h_bu.cpp new file mode 100644 index 00000000..4f34fb5f --- /dev/null +++ b/code/vaddwod_h_bu.cpp @@ -0,0 +1,9 @@ +#include "common.h" + +v128 vaddwod_h_bu(v128 a, v128 b) { + v128 dst; +#include "vaddwod_h_bu.h" + return dst; +} + +void test() { FUZZ2(vaddwod_h_bu); } diff --git a/code/vaddwod_h_bu.h b/code/vaddwod_h_bu.h new file mode 100644 index 00000000..6db4e2a0 --- /dev/null +++ b/code/vaddwod_h_bu.h @@ -0,0 +1,3 @@ +for (int i = 0; i < 8; i++) { + dst.half[i] = (u16)(u8)a.byte[2 * i + 1] + (u16)(u8)b.byte[2 * i + 1]; +} diff --git a/code/vaddwod_h_bu_b.cpp b/code/vaddwod_h_bu_b.cpp new file mode 100644 index 00000000..27eaa374 --- /dev/null +++ b/code/vaddwod_h_bu_b.cpp @@ -0,0 +1,9 @@ +#include "common.h" + +v128 vaddwod_h_bu_b(v128 a, v128 b) { + v128 dst; +#include "vaddwod_h_bu_b.h" + return dst; +} + +void test() { FUZZ2(vaddwod_h_bu_b); } diff --git a/code/vaddwod_h_bu_b.h b/code/vaddwod_h_bu_b.h new file mode 100644 index 00000000..951aab7b --- /dev/null +++ b/code/vaddwod_h_bu_b.h @@ -0,0 +1,3 @@ +for (int i = 0; i < 8; i++) { + dst.half[i] = (u16)(u8)a.byte[2 * i + 1] + (s16)(s8)b.byte[2 * i + 1]; +} diff --git a/code/vaddwod_q_d.cpp b/code/vaddwod_q_d.cpp new file mode 100644 index 00000000..1e1f26a7 --- /dev/null +++ b/code/vaddwod_q_d.cpp @@ -0,0 +1,9 @@ +#include "common.h" + +v128 vaddwod_q_d(v128 a, v128 b) { + v128 dst; +#include "vaddwod_q_d.h" + return dst; +} + +void test() { FUZZ2(vaddwod_q_d); } diff --git a/code/vaddwod_q_d.h b/code/vaddwod_q_d.h new file mode 100644 index 00000000..6bcaa62d --- /dev/null +++ b/code/vaddwod_q_d.h @@ -0,0 +1,3 @@ +for (int i = 0; i < 1; i++) { + dst.qword[i] = (s128)(s64)a.dword[2 * i + 1] + (s128)(s64)b.dword[2 * i + 1]; +} diff --git a/code/vaddwod_q_du.cpp b/code/vaddwod_q_du.cpp new file mode 100644 index 00000000..d5a8aa7a --- /dev/null +++ b/code/vaddwod_q_du.cpp @@ -0,0 +1,9 @@ +#include "common.h" + +v128 vaddwod_q_du(v128 a, v128 b) { + v128 dst; +#include "vaddwod_q_du.h" + return dst; +} + +void test() { FUZZ2(vaddwod_q_du); } diff --git a/code/vaddwod_q_du.h b/code/vaddwod_q_du.h new file mode 100644 index 00000000..47455c3e --- /dev/null +++ b/code/vaddwod_q_du.h @@ -0,0 +1,3 @@ +for (int i = 0; i < 1; i++) { + dst.qword[i] = (u128)(u64)a.dword[2 * i + 1] + (u128)(u64)b.dword[2 * i + 1]; +} diff --git a/code/vaddwod_q_du_d.cpp b/code/vaddwod_q_du_d.cpp new file mode 100644 index 00000000..8e04fefd --- /dev/null +++ b/code/vaddwod_q_du_d.cpp @@ -0,0 +1,9 @@ +#include "common.h" + +v128 vaddwod_q_du_d(v128 a, v128 b) { + v128 dst; +#include "vaddwod_q_du_d.h" + return dst; +} + +void test() { FUZZ2(vaddwod_q_du_d); } diff --git a/code/vaddwod_q_du_d.h b/code/vaddwod_q_du_d.h new file mode 100644 index 00000000..499749e1 --- /dev/null +++ b/code/vaddwod_q_du_d.h @@ -0,0 +1,3 @@ +for (int i = 0; i < 1; i++) { + dst.qword[i] = (u128)(u64)a.dword[2 * i + 1] + (s128)(s64)b.dword[2 * i + 1]; +} diff --git a/code/vaddwod_w_h.cpp b/code/vaddwod_w_h.cpp new file mode 100644 index 00000000..3eac1ce5 --- /dev/null +++ b/code/vaddwod_w_h.cpp @@ -0,0 +1,9 @@ +#include "common.h" + +v128 vaddwod_w_h(v128 a, v128 b) { + v128 dst; +#include "vaddwod_w_h.h" + return dst; +} + +void test() { FUZZ2(vaddwod_w_h); } diff --git a/code/vaddwod_w_h.h b/code/vaddwod_w_h.h new file mode 100644 index 00000000..aceba323 --- /dev/null +++ b/code/vaddwod_w_h.h @@ -0,0 +1,3 @@ +for (int i = 0; i < 4; i++) { + dst.word[i] = (s32)(s16)a.half[2 * i + 1] + (s32)(s16)b.half[2 * i + 1]; +} diff --git a/code/vaddwod_w_hu.cpp b/code/vaddwod_w_hu.cpp new file mode 100644 index 00000000..254a7773 --- /dev/null +++ b/code/vaddwod_w_hu.cpp @@ -0,0 +1,9 @@ +#include "common.h" + +v128 vaddwod_w_hu(v128 a, v128 b) { + v128 dst; +#include "vaddwod_w_hu.h" + return dst; +} + +void test() { FUZZ2(vaddwod_w_hu); } diff --git a/code/vaddwod_w_hu.h b/code/vaddwod_w_hu.h new file mode 100644 index 00000000..780351cc --- /dev/null +++ b/code/vaddwod_w_hu.h @@ -0,0 +1,3 @@ +for (int i = 0; i < 4; i++) { + dst.word[i] = (u32)(u16)a.half[2 * i + 1] + (u32)(u16)b.half[2 * i + 1]; +} diff --git a/code/vaddwod_w_hu_h.cpp b/code/vaddwod_w_hu_h.cpp new file mode 100644 index 00000000..1f9451bc --- /dev/null +++ b/code/vaddwod_w_hu_h.cpp @@ -0,0 +1,9 @@ +#include "common.h" + +v128 vaddwod_w_hu_h(v128 a, v128 b) { + v128 dst; +#include "vaddwod_w_hu_h.h" + return dst; +} + +void test() { FUZZ2(vaddwod_w_hu_h); } diff --git a/code/vaddwod_w_hu_h.h b/code/vaddwod_w_hu_h.h new file mode 100644 index 00000000..9cee5f13 --- /dev/null +++ b/code/vaddwod_w_hu_h.h @@ -0,0 +1,3 @@ +for (int i = 0; i < 4; i++) { + dst.word[i] = (u32)(u16)a.half[2 * i + 1] + (s32)(s16)b.half[2 * i + 1]; +} diff --git a/code/vand_v.cpp b/code/vand_v.cpp index 587bf52b..8d539b82 100644 --- a/code/vand_v.cpp +++ b/code/vand_v.cpp @@ -6,6 +6,4 @@ v128 vand_v(v128 a, v128 b) { return dst; } -void test() { - FUZZ2(vand_v); -} +void test() { FUZZ2(vand_v); } diff --git a/code/vandi_b.h b/code/vandi_b.h index 4c165079..4de1dcc3 100644 --- a/code/vandi_b.h +++ b/code/vandi_b.h @@ -1,3 +1,3 @@ -for (int i = 0;i < 16;i++) { - dst.byte[i] = a.byte[i] & imm; +for (int i = 0; i < 16; i++) { + dst.byte[i] = a.byte[i] & imm; } \ No newline at end of file diff --git a/code/vandn_v.cpp b/code/vandn_v.cpp index cac54574..9eb31355 100644 --- a/code/vandn_v.cpp +++ b/code/vandn_v.cpp @@ -6,6 +6,4 @@ v128 vandn_v(v128 a, v128 b) { return dst; } -void test() { - FUZZ2(vandn_v); -} +void test() { FUZZ2(vandn_v); } diff --git a/code/vavg_b.cpp b/code/vavg_b.cpp index a875a3c6..8719ab19 100644 --- a/code/vavg_b.cpp +++ b/code/vavg_b.cpp @@ -6,6 +6,4 @@ v128 vavg_b(v128 a, v128 b) { return dst; } -void test() { - FUZZ2(vavg_b); -} +void test() { FUZZ2(vavg_b); } diff --git a/code/vavg_b.h b/code/vavg_b.h index 543381ca..cdc07e78 100644 --- a/code/vavg_b.h +++ b/code/vavg_b.h @@ -1,3 +1,4 @@ -for (int i = 0;i < 16;i++) { - dst.byte[i] = ((s8)a.byte[i] >> 1) + ((s8)b.byte[i] >> 1) + (a.byte[i] & b.byte[i] & 1); +for (int i = 0; i < 16; i++) { + dst.byte[i] = + ((s8)a.byte[i] >> 1) + ((s8)b.byte[i] >> 1) + (a.byte[i] & b.byte[i] & 1); } diff --git a/code/vavg_bu.cpp b/code/vavg_bu.cpp index c76dee04..5bc33030 100644 --- a/code/vavg_bu.cpp +++ b/code/vavg_bu.cpp @@ -6,6 +6,4 @@ v128 vavg_bu(v128 a, v128 b) { return dst; } -void test() { - FUZZ2(vavg_bu); -} +void test() { FUZZ2(vavg_bu); } diff --git a/code/vavg_bu.h b/code/vavg_bu.h index 85c9794e..59f4e4a4 100644 --- a/code/vavg_bu.h +++ b/code/vavg_bu.h @@ -1,3 +1,4 @@ -for (int i = 0;i < 16;i++) { - dst.byte[i] = ((u8)a.byte[i] >> 1) + ((u8)b.byte[i] >> 1) + (a.byte[i] & b.byte[i] & 1); +for (int i = 0; i < 16; i++) { + dst.byte[i] = + ((u8)a.byte[i] >> 1) + ((u8)b.byte[i] >> 1) + (a.byte[i] & b.byte[i] & 1); } diff --git a/code/vavg_d.cpp b/code/vavg_d.cpp index b345198a..eec4fd4a 100644 --- a/code/vavg_d.cpp +++ b/code/vavg_d.cpp @@ -6,6 +6,4 @@ v128 vavg_d(v128 a, v128 b) { return dst; } -void test() { - FUZZ2(vavg_d); -} +void test() { FUZZ2(vavg_d); } diff --git a/code/vavg_d.h b/code/vavg_d.h index 7701565d..7456dd6e 100644 --- a/code/vavg_d.h +++ b/code/vavg_d.h @@ -1,3 +1,4 @@ -for (int i = 0;i < 2;i++) { - dst.dword[i] = ((s64)a.dword[i] >> 1) + ((s64)b.dword[i] >> 1) + (a.dword[i] & b.dword[i] & 1); +for (int i = 0; i < 2; i++) { + dst.dword[i] = ((s64)a.dword[i] >> 1) + ((s64)b.dword[i] >> 1) + + (a.dword[i] & b.dword[i] & 1); } diff --git a/code/vavg_du.cpp b/code/vavg_du.cpp index cc2e3386..1464fec6 100644 --- a/code/vavg_du.cpp +++ b/code/vavg_du.cpp @@ -6,6 +6,4 @@ v128 vavg_du(v128 a, v128 b) { return dst; } -void test() { - FUZZ2(vavg_du); -} +void test() { FUZZ2(vavg_du); } diff --git a/code/vavg_du.h b/code/vavg_du.h index e1897fe7..680ad0a3 100644 --- a/code/vavg_du.h +++ b/code/vavg_du.h @@ -1,3 +1,4 @@ -for (int i = 0;i < 2;i++) { - dst.dword[i] = ((u64)a.dword[i] >> 1) + ((u64)b.dword[i] >> 1) + (a.dword[i] & b.dword[i] & 1); +for (int i = 0; i < 2; i++) { + dst.dword[i] = ((u64)a.dword[i] >> 1) + ((u64)b.dword[i] >> 1) + + (a.dword[i] & b.dword[i] & 1); } diff --git a/code/vavg_h.cpp b/code/vavg_h.cpp index 38f1a490..b4bf0048 100644 --- a/code/vavg_h.cpp +++ b/code/vavg_h.cpp @@ -6,6 +6,4 @@ v128 vavg_h(v128 a, v128 b) { return dst; } -void test() { - FUZZ2(vavg_h); -} +void test() { FUZZ2(vavg_h); } diff --git a/code/vavg_h.h b/code/vavg_h.h index 43133408..f30aa6a0 100644 --- a/code/vavg_h.h +++ b/code/vavg_h.h @@ -1,3 +1,4 @@ -for (int i = 0;i < 8;i++) { - dst.half[i] = ((s16)a.half[i] >> 1) + ((s16)b.half[i] >> 1) + (a.half[i] & b.half[i] & 1); +for (int i = 0; i < 8; i++) { + dst.half[i] = ((s16)a.half[i] >> 1) + ((s16)b.half[i] >> 1) + + (a.half[i] & b.half[i] & 1); } diff --git a/code/vavg_hu.cpp b/code/vavg_hu.cpp index 5357d67e..c7b0530e 100644 --- a/code/vavg_hu.cpp +++ b/code/vavg_hu.cpp @@ -6,6 +6,4 @@ v128 vavg_hu(v128 a, v128 b) { return dst; } -void test() { - FUZZ2(vavg_hu); -} +void test() { FUZZ2(vavg_hu); } diff --git a/code/vavg_hu.h b/code/vavg_hu.h index f7b7d0f5..b61ccb71 100644 --- a/code/vavg_hu.h +++ b/code/vavg_hu.h @@ -1,3 +1,4 @@ -for (int i = 0;i < 8;i++) { - dst.half[i] = ((u16)a.half[i] >> 1) + ((u16)b.half[i] >> 1) + (a.half[i] & b.half[i] & 1); +for (int i = 0; i < 8; i++) { + dst.half[i] = ((u16)a.half[i] >> 1) + ((u16)b.half[i] >> 1) + + (a.half[i] & b.half[i] & 1); } diff --git a/code/vavg_w.cpp b/code/vavg_w.cpp index cbf49128..bae40ee0 100644 --- a/code/vavg_w.cpp +++ b/code/vavg_w.cpp @@ -6,6 +6,4 @@ v128 vavg_w(v128 a, v128 b) { return dst; } -void test() { - FUZZ2(vavg_w); -} +void test() { FUZZ2(vavg_w); } diff --git a/code/vavg_w.h b/code/vavg_w.h index 0f258e56..d64bbf3a 100644 --- a/code/vavg_w.h +++ b/code/vavg_w.h @@ -1,3 +1,4 @@ -for (int i = 0;i < 4;i++) { - dst.word[i] = ((s32)a.word[i] >> 1) + ((s32)b.word[i] >> 1) + (a.word[i] & b.word[i] & 1); +for (int i = 0; i < 4; i++) { + dst.word[i] = ((s32)a.word[i] >> 1) + ((s32)b.word[i] >> 1) + + (a.word[i] & b.word[i] & 1); } diff --git a/code/vavg_wu.cpp b/code/vavg_wu.cpp index f773c737..cbbd1049 100644 --- a/code/vavg_wu.cpp +++ b/code/vavg_wu.cpp @@ -6,6 +6,4 @@ v128 vavg_wu(v128 a, v128 b) { return dst; } -void test() { - FUZZ2(vavg_wu); -} +void test() { FUZZ2(vavg_wu); } diff --git a/code/vavg_wu.h b/code/vavg_wu.h index 22764aa9..d2599aa2 100644 --- a/code/vavg_wu.h +++ b/code/vavg_wu.h @@ -1,3 +1,4 @@ -for (int i = 0;i < 4;i++) { - dst.word[i] = ((u32)a.word[i] >> 1) + ((u32)b.word[i] >> 1) + (a.word[i] & b.word[i] & 1); +for (int i = 0; i < 4; i++) { + dst.word[i] = ((u32)a.word[i] >> 1) + ((u32)b.word[i] >> 1) + + (a.word[i] & b.word[i] & 1); } diff --git a/code/vavgr_b.cpp b/code/vavgr_b.cpp index 45b565d5..e46997d7 100644 --- a/code/vavgr_b.cpp +++ b/code/vavgr_b.cpp @@ -6,6 +6,4 @@ v128 vavgr_b(v128 a, v128 b) { return dst; } -void test() { - FUZZ2(vavgr_b); -} +void test() { FUZZ2(vavgr_b); } diff --git a/code/vavgr_b.h b/code/vavgr_b.h index 058d7ccb..6613b474 100644 --- a/code/vavgr_b.h +++ b/code/vavgr_b.h @@ -1,3 +1,4 @@ -for (int i = 0;i < 16;i++) { - dst.byte[i] = ((s8)a.byte[i] >> 1) + ((s8)b.byte[i] >> 1) + ((a.byte[i] | b.byte[i]) & 1); +for (int i = 0; i < 16; i++) { + dst.byte[i] = ((s8)a.byte[i] >> 1) + ((s8)b.byte[i] >> 1) + + ((a.byte[i] | b.byte[i]) & 1); } diff --git a/code/vavgr_bu.cpp b/code/vavgr_bu.cpp index ae3560f4..a1da3b9c 100644 --- a/code/vavgr_bu.cpp +++ b/code/vavgr_bu.cpp @@ -6,6 +6,4 @@ v128 vavgr_bu(v128 a, v128 b) { return dst; } -void test() { - FUZZ2(vavgr_bu); -} +void test() { FUZZ2(vavgr_bu); } diff --git a/code/vavgr_bu.h b/code/vavgr_bu.h index 7729c4c4..1633ce19 100644 --- a/code/vavgr_bu.h +++ b/code/vavgr_bu.h @@ -1,3 +1,4 @@ -for (int i = 0;i < 16;i++) { - dst.byte[i] = ((u8)a.byte[i] >> 1) + ((u8)b.byte[i] >> 1) + ((a.byte[i] | b.byte[i]) & 1); +for (int i = 0; i < 16; i++) { + dst.byte[i] = ((u8)a.byte[i] >> 1) + ((u8)b.byte[i] >> 1) + + ((a.byte[i] | b.byte[i]) & 1); } diff --git a/code/vavgr_d.cpp b/code/vavgr_d.cpp index 8aef6c85..28f3780b 100644 --- a/code/vavgr_d.cpp +++ b/code/vavgr_d.cpp @@ -6,6 +6,4 @@ v128 vavgr_d(v128 a, v128 b) { return dst; } -void test() { - FUZZ2(vavgr_d); -} +void test() { FUZZ2(vavgr_d); } diff --git a/code/vavgr_d.h b/code/vavgr_d.h index 6cab2fdf..62df5ce6 100644 --- a/code/vavgr_d.h +++ b/code/vavgr_d.h @@ -1,3 +1,4 @@ -for (int i = 0;i < 2;i++) { - dst.dword[i] = ((s64)a.dword[i] >> 1) + ((s64)b.dword[i] >> 1) + ((a.dword[i] | b.dword[i]) & 1); +for (int i = 0; i < 2; i++) { + dst.dword[i] = ((s64)a.dword[i] >> 1) + ((s64)b.dword[i] >> 1) + + ((a.dword[i] | b.dword[i]) & 1); } diff --git a/code/vavgr_du.cpp b/code/vavgr_du.cpp index 18cccf37..5f3726f0 100644 --- a/code/vavgr_du.cpp +++ b/code/vavgr_du.cpp @@ -6,6 +6,4 @@ v128 vavgr_du(v128 a, v128 b) { return dst; } -void test() { - FUZZ2(vavgr_du); -} +void test() { FUZZ2(vavgr_du); } diff --git a/code/vavgr_du.h b/code/vavgr_du.h index aaf0844a..97e17d73 100644 --- a/code/vavgr_du.h +++ b/code/vavgr_du.h @@ -1,3 +1,4 @@ -for (int i = 0;i < 2;i++) { - dst.dword[i] = ((u64)a.dword[i] >> 1) + ((u64)b.dword[i] >> 1) + ((a.dword[i] | b.dword[i]) & 1); +for (int i = 0; i < 2; i++) { + dst.dword[i] = ((u64)a.dword[i] >> 1) + ((u64)b.dword[i] >> 1) + + ((a.dword[i] | b.dword[i]) & 1); } diff --git a/code/vavgr_h.cpp b/code/vavgr_h.cpp index b887027b..1f3f4984 100644 --- a/code/vavgr_h.cpp +++ b/code/vavgr_h.cpp @@ -6,6 +6,4 @@ v128 vavgr_h(v128 a, v128 b) { return dst; } -void test() { - FUZZ2(vavgr_h); -} +void test() { FUZZ2(vavgr_h); } diff --git a/code/vavgr_h.h b/code/vavgr_h.h index 6213fd2d..4a24bb54 100644 --- a/code/vavgr_h.h +++ b/code/vavgr_h.h @@ -1,3 +1,4 @@ -for (int i = 0;i < 8;i++) { - dst.half[i] = ((s16)a.half[i] >> 1) + ((s16)b.half[i] >> 1) + ((a.half[i] | b.half[i]) & 1); +for (int i = 0; i < 8; i++) { + dst.half[i] = ((s16)a.half[i] >> 1) + ((s16)b.half[i] >> 1) + + ((a.half[i] | b.half[i]) & 1); } diff --git a/code/vavgr_hu.cpp b/code/vavgr_hu.cpp index 4b397e3c..53525e47 100644 --- a/code/vavgr_hu.cpp +++ b/code/vavgr_hu.cpp @@ -6,6 +6,4 @@ v128 vavgr_hu(v128 a, v128 b) { return dst; } -void test() { - FUZZ2(vavgr_hu); -} +void test() { FUZZ2(vavgr_hu); } diff --git a/code/vavgr_hu.h b/code/vavgr_hu.h index 7b4a738f..22602f81 100644 --- a/code/vavgr_hu.h +++ b/code/vavgr_hu.h @@ -1,3 +1,4 @@ -for (int i = 0;i < 8;i++) { - dst.half[i] = ((u16)a.half[i] >> 1) + ((u16)b.half[i] >> 1) + ((a.half[i] | b.half[i]) & 1); +for (int i = 0; i < 8; i++) { + dst.half[i] = ((u16)a.half[i] >> 1) + ((u16)b.half[i] >> 1) + + ((a.half[i] | b.half[i]) & 1); } diff --git a/code/vavgr_w.cpp b/code/vavgr_w.cpp index bf27f0ab..061be194 100644 --- a/code/vavgr_w.cpp +++ b/code/vavgr_w.cpp @@ -6,6 +6,4 @@ v128 vavgr_w(v128 a, v128 b) { return dst; } -void test() { - FUZZ2(vavgr_w); -} +void test() { FUZZ2(vavgr_w); } diff --git a/code/vavgr_w.h b/code/vavgr_w.h index bbc8de83..1cfb7a98 100644 --- a/code/vavgr_w.h +++ b/code/vavgr_w.h @@ -1,3 +1,4 @@ -for (int i = 0;i < 4;i++) { - dst.word[i] = ((s32)a.word[i] >> 1) + ((s32)b.word[i] >> 1) + ((a.word[i] | b.word[i]) & 1); +for (int i = 0; i < 4; i++) { + dst.word[i] = ((s32)a.word[i] >> 1) + ((s32)b.word[i] >> 1) + + ((a.word[i] | b.word[i]) & 1); } diff --git a/code/vavgr_wu.cpp b/code/vavgr_wu.cpp index 5538af0d..d346df29 100644 --- a/code/vavgr_wu.cpp +++ b/code/vavgr_wu.cpp @@ -6,6 +6,4 @@ v128 vavgr_wu(v128 a, v128 b) { return dst; } -void test() { - FUZZ2(vavgr_wu); -} +void test() { FUZZ2(vavgr_wu); } diff --git a/code/vavgr_wu.h b/code/vavgr_wu.h index 29605e2c..0cfa02e0 100644 --- a/code/vavgr_wu.h +++ b/code/vavgr_wu.h @@ -1,3 +1,4 @@ -for (int i = 0;i < 4;i++) { - dst.word[i] = ((u32)a.word[i] >> 1) + ((u32)b.word[i] >> 1) + ((a.word[i] | b.word[i]) & 1); +for (int i = 0; i < 4; i++) { + dst.word[i] = ((u32)a.word[i] >> 1) + ((u32)b.word[i] >> 1) + + ((a.word[i] | b.word[i]) & 1); } diff --git a/code/vbitsel_v.cpp b/code/vbitsel_v.cpp index 36ce706a..d4e7ba73 100644 --- a/code/vbitsel_v.cpp +++ b/code/vbitsel_v.cpp @@ -6,6 +6,4 @@ v128 vbitsel_v(v128 a, v128 b, v128 c) { return dst; } -void test() { - FUZZ3(vbitsel_v); -} +void test() { FUZZ3(vbitsel_v); } diff --git a/code/vldrepl_b.h b/code/vldrepl_b.h index f9e6150b..8c6da03d 100644 --- a/code/vldrepl_b.h +++ b/code/vldrepl_b.h @@ -1,4 +1,4 @@ u8 data = memory_load(8, addr + offset); -for (int i = 0;i < 16;i++) { - dst.byte[i] = data; +for (int i = 0; i < 16; i++) { + dst.byte[i] = data; } diff --git a/code/vldrepl_d.h b/code/vldrepl_d.h index 01c5d808..9586fd48 100644 --- a/code/vldrepl_d.h +++ b/code/vldrepl_d.h @@ -1,4 +1,4 @@ u64 data = memory_load(64, addr + (offset << 3)); -for (int i = 0;i < 2;i++) { - dst.dword[i] = data; +for (int i = 0; i < 2; i++) { + dst.dword[i] = data; } diff --git a/code/vldrepl_h.h b/code/vldrepl_h.h index 94f5cc15..bf517e3b 100644 --- a/code/vldrepl_h.h +++ b/code/vldrepl_h.h @@ -1,4 +1,4 @@ u16 data = memory_load(16, addr + (offset << 1)); -for (int i = 0;i < 8;i++) { - dst.half[i] = data; +for (int i = 0; i < 8; i++) { + dst.half[i] = data; } diff --git a/code/vldrepl_w.h b/code/vldrepl_w.h index 1d45f27a..951d8ba0 100644 --- a/code/vldrepl_w.h +++ b/code/vldrepl_w.h @@ -1,4 +1,4 @@ u32 data = memory_load(32, addr + (offset << 2)); -for (int i = 0;i < 4;i++) { - dst.word[i] = data; +for (int i = 0; i < 4; i++) { + dst.word[i] = data; } \ No newline at end of file diff --git a/code/vshuf_b.cpp b/code/vshuf_b.cpp index 5ab2098f..f0b6a0c2 100644 --- a/code/vshuf_b.cpp +++ b/code/vshuf_b.cpp @@ -6,6 +6,4 @@ v128 vshuf_b(v128 a, v128 b, v128 c) { return dst; } -void test() { - FUZZ3(vshuf_b); -} +void test() { FUZZ3(vshuf_b); } diff --git a/code/vshuf_h.cpp b/code/vshuf_h.cpp index 57f82422..04af93a5 100644 --- a/code/vshuf_h.cpp +++ b/code/vshuf_h.cpp @@ -6,6 +6,4 @@ v128 vshuf_h(v128 a, v128 b, v128 c) { return dst; } -void test() { - FUZZ3(vshuf_h); -} +void test() { FUZZ3(vshuf_h); } diff --git a/code/vshuf_w.cpp b/code/vshuf_w.cpp index d6a921ef..e202675f 100644 --- a/code/vshuf_w.cpp +++ b/code/vshuf_w.cpp @@ -6,6 +6,4 @@ v128 vshuf_w(v128 a, v128 b, v128 c) { return dst; } -void test() { - FUZZ3(vshuf_w); -} +void test() { FUZZ3(vshuf_w); } diff --git a/docs/lsx_integer/vaddsub.md b/docs/lsx_integer/vaddsub.md index 2b40484c..506aca2e 100644 --- a/docs/lsx_integer/vaddsub.md +++ b/docs/lsx_integer/vaddsub.md @@ -38,6 +38,19 @@ {{ vaddwev('q', 'du') }} {{ vaddwev('q', 'du', 'd') }} +{{ vaddwod('h', 'b') }} +{{ vaddwod('h', 'bu') }} +{{ vaddwod('h', 'bu', 'b') }} +{{ vaddwod('w', 'h') }} +{{ vaddwod('w', 'hu') }} +{{ vaddwod('w', 'hu', 'h') }} +{{ vaddwod('d', 'w') }} +{{ vaddwod('d', 'wu') }} +{{ vaddwod('d', 'wu', 'w') }} +{{ vaddwod('q', 'd') }} +{{ vaddwod('q', 'du') }} +{{ vaddwod('q', 'du', 'd') }} + {{ vavg('b') }} {{ vavg('bu') }} {{ vavg('h') }} diff --git a/main.py b/main.py index b92ad026..728e89d5 100644 --- a/main.py +++ b/main.py @@ -117,6 +117,25 @@ def vaddwev(wide, narrow, narrow2=None): desc=f"Add even-positioned {signedness} {narrow_width}-bit elements in `a` and {signedness2} elements in `b`, save the {wide_width}-bit result in `dst`.", ) + @env.macro + def vaddwod(wide, narrow, narrow2=None): + wide_width = widths[wide] + if narrow2 is None: + narrow2 = narrow + inst_suffix = "" + intrinsic_suffix = "" + else: + inst_suffix = f".{narrow2}" + intrinsic_suffix = f"_{narrow2}" + narrow_width = widths[narrow] + signedness = signednesses[narrow] + signedness2 = signednesses[narrow2] + return instruction( + intrinsic=f"__m128i __lsx_vaddwod_{wide}_{narrow}{intrinsic_suffix} (__m128i a, __m128i b)", + instr=f"vaddwod.{wide}.{narrow}{inst_suffix} vr, vr, vr", + desc=f"Add odd-positioned {signedness} {narrow_width}-bit elements in `a` and {signedness2} elements in `b`, save the {wide_width}-bit result in `dst`.", + ) + @env.macro def vavg(name): width = widths[name]