From: Richard Henderson <richard.henderson@linaro.org>
To: Stephen Long <steplong@quicinc.com>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: "qemu-arm@nongnu.org" <qemu-arm@nongnu.org>,
Ana Pazos <apazos@quicinc.com>
Subject: Re: [PATCH RFC] target/arm: Implement SVE2 TBL, TBX
Date: Fri, 24 Apr 2020 17:25:17 -0700 [thread overview]
Message-ID: <b41a6863-d319-c437-c2a6-05c1172b3fa9@linaro.org> (raw)
In-Reply-To: <MWHPR0201MB354724516113DC31C0CFCD50C7D00@MWHPR0201MB3547.namprd02.prod.outlook.com>
On 4/24/20 3:47 PM, Stephen Long wrote:
> Oh, maybe I misread the manual description for SVE2 TBL, but I thought Zm was the indexes register and the loop compares the index from Zm with the total number of elems, table_elems.
That's right. You take the index from Zm just fine, but fail to apply that
index properly across Zn and Zn+1.
r~
>
> -----Original Message-----
> From: Richard Henderson <richard.henderson@linaro.org>
> Sent: Friday, April 24, 2020 2:37 PM
> To: Stephen Long <steplong@quicinc.com>; qemu-devel@nongnu.org
> Cc: qemu-arm@nongnu.org; Ana Pazos <apazos@quicinc.com>
> Subject: [EXT] Re: [PATCH RFC] target/arm: Implement SVE2 TBL, TBX
>
> On 4/23/20 9:42 AM, Stephen Long wrote:
>> Signed-off-by: Stephen Long <steplong@quicinc.com>
>>
>> These insns don't show up under any SVE2 categories in the manual. But
>> if you lookup each insn, you'll find they have SVE2 variants.
>> ---
>> target/arm/helper-sve.h | 10 +++++++
>> target/arm/sve.decode | 5 ++++
>> target/arm/sve_helper.c | 53 ++++++++++++++++++++++++++++++++++++++
>> target/arm/translate-sve.c | 20 ++++++++++++++
>> 4 files changed, 88 insertions(+)
>>
>> diff --git a/target/arm/helper-sve.h b/target/arm/helper-sve.h index
>> f6ae814021..54d20575e8 100644
>> --- a/target/arm/helper-sve.h
>> +++ b/target/arm/helper-sve.h
>> @@ -2687,3 +2687,13 @@ DEF_HELPER_FLAGS_5(sve2_sqrdcmlah_zzzz_s, TCG_CALL_NO_RWG,
>> void, ptr, ptr, ptr, ptr, i32)
>> DEF_HELPER_FLAGS_5(sve2_sqrdcmlah_zzzz_d, TCG_CALL_NO_RWG,
>> void, ptr, ptr, ptr, ptr, i32)
>> +
>> +DEF_HELPER_FLAGS_5(sve2_tbl_b, TCG_CALL_NO_RWG, void, ptr, ptr, ptr,
>> +ptr, i32) DEF_HELPER_FLAGS_5(sve2_tbl_h, TCG_CALL_NO_RWG, void, ptr,
>> +ptr, ptr, ptr, i32) DEF_HELPER_FLAGS_5(sve2_tbl_s, TCG_CALL_NO_RWG,
>> +void, ptr, ptr, ptr, ptr, i32) DEF_HELPER_FLAGS_5(sve2_tbl_d,
>> +TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32)
>> +
>> +DEF_HELPER_FLAGS_4(sve2_tbx_b, TCG_CALL_NO_RWG, void, ptr, ptr, ptr,
>> +i32) DEF_HELPER_FLAGS_4(sve2_tbx_h, TCG_CALL_NO_RWG, void, ptr, ptr,
>> +ptr, i32) DEF_HELPER_FLAGS_4(sve2_tbx_s, TCG_CALL_NO_RWG, void, ptr,
>> +ptr, ptr, i32) DEF_HELPER_FLAGS_4(sve2_tbx_d, TCG_CALL_NO_RWG, void,
>> +ptr, ptr, ptr, i32)
>> diff --git a/target/arm/sve.decode b/target/arm/sve.decode index
>> 3a2a4a7f1c..483fbf0dcc 100644
>> --- a/target/arm/sve.decode
>> +++ b/target/arm/sve.decode
>> @@ -1387,3 +1387,8 @@ UMLSLT_zzzw 01000100 .. 0 ..... 010 111 ..... ..... @rda_rn_rm
>>
>> CMLA_zzzz 01000100 esz:2 0 rm:5 0010 rot:2 rn:5 rd:5 ra=%reg_movprfx
>> SQRDCMLAH_zzzz 01000100 esz:2 0 rm:5 0011 rot:2 rn:5 rd:5
>> ra=%reg_movprfx
>> +
>> +### SVE2 Table Lookup (three sources)
>> +
>> +TBL_zzz 00000101 .. 1 ..... 00101 0 ..... ..... @rd_rn_rm
>> +TBX_zzz 00000101 .. 1 ..... 00101 1 ..... ..... @rd_rn_rm
>> diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c index
>> 55e2c32f03..d1e91da02a 100644
>> --- a/target/arm/sve_helper.c
>> +++ b/target/arm/sve_helper.c
>> @@ -2968,6 +2968,59 @@ DO_TBL(sve_tbl_d, uint64_t, )
>>
>> #undef TBL
>>
>> +#define DO_SVE2_TBL(NAME, TYPE, H) \
>> +void HELPER(NAME)(void *vd, void *vn1, void *vm, void *vn2, uint32_t desc) \
>> +{ \
>> + intptr_t i, opr_sz = simd_oprsz(desc); \
>> + uintptr_t elem = opr_sz / sizeof(TYPE); \
>> + TYPE *d = vd, *n1 = vn1, *n2 = vn2, *m = vm; \
>> + ARMVectorReg tmp1, tmp2; \
>
> Only one temp needed.
>
>> + if (unlikely(vd == vn1)) { \
>> + n1 = memcpy(&tmp1, vn1, opr_sz); \
>> + } \
>> + if (unlikely(vd == vn2)) { \
>> + n2 = memcpy(&tmp2, vn2, opr_sz); \
>> + }
>
> Better with else if here.
> Because vd cannot overlap both vn1 or vn2, only one of them.
> \
>> + for (i = 0; i < elem; i++) { \
>> + TYPE j = m[H(i)]; \
>> + d[H(i)] = j < (elem * 2) ? n1[H(j)] : 0; \
>> + \
>> + TYPE k = m[H(elem + i)]; \
>> + d[H(elem + i)] = k < (elem * 2) ? n2[H(k)] : 0; \
>> + }
>
> First, the indexing is wrong.
>
> Note that you're range checking vs elem * 2, but only indexing a single vector.
> Thus you must be indexing into the next vector.
>
> This should look more like
>
> TYPE j = m[H(i)];
> TYPE r = 0;
>
> if (j < elem) {
> r = n1[H(j)];
> } else if (j < 2 * elem) {
> r = n2[H(j - elem)];
> }
> d[H(i)] = r;
>
> Second, this is one case where I'd prefer to share code with AArch64. It would be worthwhile to rearrange both sve1 and advsimd to use a common set of helpers.
>
>> +static bool trans_TBL_zzz(DisasContext *s, arg_rrr_esz *a)
>
> _zzz is not helpful here. The SVE1 insn also operates on 3 registers, and thus could logically be _zzz too.
>
> Better might be _double, after double_table = TRUE, or maybe just _2 just in case SVE3 adds a variant with more table registers.
>
>
> r~
>
prev parent reply other threads:[~2020-04-25 0:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-23 16:42 [PATCH RFC] target/arm: Implement SVE2 TBL, TBX Stephen Long
2020-04-24 21:37 ` Richard Henderson
2020-04-24 22:47 ` Stephen Long
2020-04-25 0:25 ` Richard Henderson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b41a6863-d319-c437-c2a6-05c1172b3fa9@linaro.org \
--to=richard.henderson@linaro.org \
--cc=apazos@quicinc.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=steplong@quicinc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).