All of lore.kernel.org
 help / color / mirror / Atom feed
From: gaosong <gaosong@loongson.cn>
To: Richard Henderson <richard.henderson@linaro.org>, qemu-devel@nongnu.org
Subject: Re: [RFC PATCH 10/43] target/loongarch: Implement vaddw/vsubw
Date: Mon, 27 Feb 2023 17:14:00 +0800	[thread overview]
Message-ID: <d052497f-fc2c-17ab-d455-f0a1727b422d@loongson.cn> (raw)
In-Reply-To: <c5913a52-e5de-4fb5-688c-6d3fb3215353@linaro.org>


在 2023/2/25 上午3:24, Richard Henderson 写道:
> On 2/23/23 21:24, gaosong wrote:
>> I was wrong, the instruction is to sign-extend the odd or even 
>> elements of the vector before the operation, not to sign-extend the 
>> result.
>> E.g
>> vaddwev_h_b  vd, vj, vk
>> vd->H[i] = SignExtend(vj->B[2i])  + SignExtend(vk->B[2i]);
>> vaddwev_w_h  vd, vj, vk
>> vd->W[i] = SignExtend(vj->H[2i])  + SignExtend(vk->H[2i]);
>> vaddwev_d_w  vd, vj, vk
>> vd->Q[i] = SignExtend(vj->W[2i])  + SignExtend(vk->W[2i]);
>> vaddwev_q_d  vd, vj, vk
>> vd->Q[i] = SignExtend(vj->D[2i])  + SignExtend(vk->D[2i]);
>
> Ok, good example.
>
Sorry ,  My description is not comprehensive.

vaddwedv_w_h  vd, vj, vk

...

for i in range(4):
     vd->W[i] = SignExtend(vj->H[2i], 32)  + SignExtend(vk->H[2i]. 32);

...

>> static void gen_vaddwev_s(unsigned vece, TCGv_vec t, TCGv_vec a, 
>> TCGv_vec b)
>> {
>>      TCGv_vec t1 = tcg_temp_new_vec_matching(a);
>>      TCGv_vec t2 = tcg_temp_new_vec_matching(b);
>>
>>      int halfbits  =  4 << vece;
>>
>>      /* Sign-extend even elements from a */
>>      tcg_gen_dupi_vec(vece, t1, MAKE_64BIT_MASK(0, halfbits));
>>      tcg_gen_and_vec(vece, a, a, t1);
>
> No need to mask off these bits...
>
I am not sure.  but the result is not correct.   It's  weird.


like this:
the vece is MO_32.
static void gen_vaddwev_s(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec b)
{
     TCGv_vec t1 = tcg_temp_new_vec_matching(a);
     TCGv_vec t2 = tcg_temp_new_vec_matching(b);
     int halfbits = 4 << vece;
     tcg_gen_shli_vec(vece, t1, a, halfbits);
     tcg_gen_shri_vec(vece, t1, t1, halfbits);

     tcg_gen_shli_vec(vece, t2, b,  halfbits);
     tcg_gen_shri_vec(vece, t2, t2, halfbits);

     tcg_gen_add_vec(vece, t, t1, t2);

     tcg_temp_free_vec(t1);
     tcg_temp_free_vec(t2);
}
...
        op[MO_16];
         {
             .fniv = gen_vaddwev_s,
             .fno = gen_helper_vaddwev_w_h,
             .opt_opc = vecop_list,
             .vece = MO_32
         },
...
TRANS(vaddwev_w_h, gvec_vvv, MO_16, gvec_vaddwev_s)

input :       0x ffff     fffe ffff     fffe   ffff    fffe ffff fffe  + 0
output :    0x 0000 fffe 0000 fffe  0000 fffe 0000 fffe
the crroect is  0xffffffffefffffffefffffffefffffffe.

Thanks.
Song Gao
>>      tcg_gen_shli_vec(vece, a, a, halfbits);
>
> ... because they shift out here anyway.
>
>>      tcg_gen_sari_vec(vece, a, a, halfbits);
>>
>>      /* Sign-extend even elements from b */
>>      tcg_gen_dupi_vec(vece, t2, MAKE_64BIT_MASK(0, halfbits));
>>      tcg_gen_and_vec(vece, b, b, t2);
>>      tcg_gen_shli_vec(vece, b, b, halfbits);
>>      tcg_gen_sari_vec(vece,  b, b, halfbits);
>>
>>      tcg_gen_add_vec(vece, t, a, b);
>>
>>      tcg_temp_free_vec(t1);
>>      tcg_temp_free_vec(t2);
>> }
>
> Otherwise this looks good.



  reply	other threads:[~2023-02-27  9:14 UTC|newest]

Thread overview: 100+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-24  8:15 [RFC PATCH 00/43] Add LoongArch LSX instructions Song Gao
2022-12-24  8:15 ` [RFC PATCH 01/43] target/loongarch: Add vector data type vec_t Song Gao
2022-12-24 17:07   ` Richard Henderson
2022-12-24 17:24   ` Richard Henderson
2022-12-28  2:34     ` gaosong
2022-12-28 17:30       ` Richard Henderson
2022-12-29  1:51         ` gaosong
2022-12-29  3:13           ` Richard Henderson
2022-12-29  3:54             ` gaosong
2022-12-24 17:32   ` Richard Henderson
2023-02-13  8:24     ` gaosong
2023-02-13 19:18       ` Richard Henderson
2022-12-24  8:15 ` [RFC PATCH 02/43] target/loongarch: CPUCFG support LSX Song Gao
2022-12-24  8:15 ` [RFC PATCH 03/43] target/loongarch: meson.build support build LSX Song Gao
2022-12-24  8:15 ` [RFC PATCH 04/43] target/loongarch: Add CHECK_SXE maccro for check LSX enable Song Gao
2022-12-24  8:15 ` [RFC PATCH 05/43] target/loongarch: Implement vadd/vsub Song Gao
2022-12-24 17:16   ` Richard Henderson
2022-12-24  8:15 ` [RFC PATCH 06/43] target/loongarch: Implement vaddi/vsubi Song Gao
2022-12-24 17:27   ` Richard Henderson
2022-12-24  8:15 ` [RFC PATCH 07/43] target/loongarch: Implement vneg Song Gao
2022-12-24 17:29   ` Richard Henderson
2022-12-24  8:15 ` [RFC PATCH 08/43] target/loongarch: Implement vsadd/vssub Song Gao
2022-12-24 17:31   ` Richard Henderson
2022-12-24  8:15 ` [RFC PATCH 09/43] target/loongarch: Implement vhaddw/vhsubw Song Gao
2022-12-24 17:41   ` Richard Henderson
2022-12-24  8:16 ` [RFC PATCH 10/43] target/loongarch: Implement vaddw/vsubw Song Gao
2022-12-24 17:48   ` Richard Henderson
2023-02-20  7:47     ` gaosong
2023-02-20 17:21       ` Richard Henderson
2023-02-23  8:23         ` gaosong
2023-02-23 15:22           ` Richard Henderson
2023-02-24  7:24             ` gaosong
2023-02-24 19:24               ` Richard Henderson
2023-02-27  9:14                 ` gaosong [this message]
2023-02-27  9:20                   ` Richard Henderson
2023-02-27 12:54                     ` gaosong
2023-02-27 18:32                       ` Richard Henderson
2023-02-27 12:55                 ` gaosong
2023-02-27 18:40                   ` Richard Henderson
2023-02-28  3:30                     ` gaosong
2023-02-28 16:48                       ` Richard Henderson
2023-02-24 23:01               ` Richard Henderson
2023-02-28  7:44                 ` gaosong
2023-02-28 16:50                   ` Richard Henderson
2022-12-24  8:16 ` [RFC PATCH 11/43] target/loongarch: Implement vavg/vavgr Song Gao
2022-12-24 17:52   ` Richard Henderson
2022-12-24  8:16 ` [RFC PATCH 12/43] target/loongarch: Implement vabsd Song Gao
2022-12-24 17:55   ` Richard Henderson
2022-12-24  8:16 ` [RFC PATCH 13/43] target/loongarch: Implement vadda Song Gao
2022-12-24 17:56   ` Richard Henderson
2022-12-24  8:16 ` [RFC PATCH 14/43] target/loongarch: Implement vmax/vmin Song Gao
2022-12-24 18:01   ` Richard Henderson
2022-12-24  8:16 ` [RFC PATCH 15/43] target/loongarch: Implement vmul/vmuh/vmulw{ev/od} Song Gao
2022-12-24 18:07   ` Richard Henderson
2022-12-24  8:16 ` [RFC PATCH 16/43] target/loongarch: Implement vmadd/vmsub/vmaddw{ev/od} Song Gao
2022-12-24 18:09   ` Richard Henderson
2022-12-24  8:16 ` [RFC PATCH 17/43] target/loongarch: Implement vdiv/vmod Song Gao
2022-12-24  8:16 ` [RFC PATCH 18/43] target/loongarch: Implement vsat Song Gao
2022-12-24 18:13   ` Richard Henderson
2022-12-24  8:16 ` [RFC PATCH 19/43] target/loongarch: Implement vexth Song Gao
2022-12-24  8:16 ` [RFC PATCH 20/43] target/loongarch: Implement vsigncov Song Gao
2022-12-24 18:18   ` Richard Henderson
2022-12-24  8:16 ` [RFC PATCH 21/43] target/loongarch: Implement vmskltz/vmskgez/vmsknz Song Gao
2022-12-24 18:31   ` Richard Henderson
2022-12-24  8:16 ` [RFC PATCH 22/43] target/loongarch: Implement LSX logic instructions Song Gao
2022-12-24 18:34   ` Richard Henderson
2022-12-24  8:16 ` [RFC PATCH 23/43] target/loongarch: Implement vsll vsrl vsra vrotr Song Gao
2022-12-24 18:36   ` Richard Henderson
2022-12-24  8:16 ` [RFC PATCH 24/43] target/loongarch: Implement vsllwil vextl Song Gao
2022-12-24  8:16 ` [RFC PATCH 25/43] target/loongarch: Implement vsrlr vsrar Song Gao
2022-12-24  8:16 ` [RFC PATCH 26/43] target/loongarch: Implement vsrln vsran Song Gao
2022-12-24  8:16 ` [RFC PATCH 27/43] target/loongarch: Implement vsrlrn vsrarn Song Gao
2022-12-24  8:16 ` [RFC PATCH 28/43] target/loongarch: Implement vssrln vssran Song Gao
2022-12-24  8:16 ` [RFC PATCH 29/43] target/loongarch: Implement vssrlrn vssrarn Song Gao
2022-12-24  8:16 ` [RFC PATCH 30/43] target/loongarch: Implement vclo vclz Song Gao
2022-12-24  8:16 ` [RFC PATCH 31/43] target/loongarch: Implement vpcnt Song Gao
2022-12-24  8:16 ` [RFC PATCH 32/43] target/loongarch: Implement vbitclr vbitset vbitrev Song Gao
2022-12-24  8:16 ` [RFC PATCH 33/43] target/loongarch: Implement vfrstp Song Gao
2022-12-24  8:16 ` [RFC PATCH 34/43] target/loongarch: Implement LSX fpu arith instructions Song Gao
2022-12-24  8:16 ` [RFC PATCH 35/43] target/loongarch: Implement LSX fpu fcvt instructions Song Gao
2022-12-24  8:16 ` [RFC PATCH 36/43] target/loongarch: Implement vseq vsle vslt Song Gao
2022-12-24 18:50   ` Richard Henderson
2022-12-24  8:16 ` [RFC PATCH 37/43] target/loongarch: Implement vfcmp Song Gao
2022-12-24  8:16 ` [RFC PATCH 38/43] target/loongarch: Implement vbitsel vset Song Gao
2022-12-24 19:15   ` Richard Henderson
2022-12-24  8:16 ` [RFC PATCH 39/43] target/loongarch: Implement vinsgr2vr vpickve2gr vreplgr2vr Song Gao
2022-12-24 20:34   ` Richard Henderson
2022-12-24  8:16 ` [RFC PATCH 40/43] target/loongarch: Implement vreplve vpack vpick Song Gao
2022-12-24 21:12   ` Richard Henderson
2023-03-21 11:31     ` gaosong
2023-03-21 15:55       ` Richard Henderson
2023-03-22  8:32         ` gaosong
2023-03-22 12:35           ` Richard Henderson
2022-12-24  8:16 ` [RFC PATCH 41/43] target/loongarch: Implement vilvl vilvh vextrins vshuf Song Gao
2022-12-24  8:16 ` [RFC PATCH 42/43] target/loongarch: Implement vld vst Song Gao
2022-12-24 21:15   ` Richard Henderson
2022-12-24  8:16 ` [RFC PATCH 43/43] target/loongarch: Implement vldi Song Gao
2022-12-24 21:18   ` Richard Henderson
2022-12-24 15:39 ` [RFC PATCH 00/43] Add LoongArch LSX instructions Richard Henderson
2022-12-28  0:55   ` gaosong

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=d052497f-fc2c-17ab-d455-f0a1727b422d@loongson.cn \
    --to=gaosong@loongson.cn \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.