All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Matheus K. Ferst" <matheus.ferst@eldorado.org.br>
To: Richard Henderson <richard.henderson@linaro.org>, qemu-devel@nongnu.org
Cc: david@redhat.com
Subject: Re: [PATCH v5 01/16] tcg: Expand usadd/ussub with umin/umax
Date: Fri, 17 Sep 2021 08:24:43 -0300	[thread overview]
Message-ID: <d5d876e5-e22b-290c-1510-3c77cc29f357@eldorado.org.br> (raw)
In-Reply-To: <20210915213114.1923776-2-richard.henderson@linaro.org>

On 15/09/2021 18:30, Richard Henderson wrote:
> [E-MAIL EXTERNO] Não clique em links ou abra anexos, a menos que você possa confirmar o remetente e saber que o conteúdo é seguro. Em caso de e-mail suspeito entre imediatamente em contato com o DTI.
> 
> For usadd, we only have to consider overflow.  Since ~B + B == -1,
> the maximum value for A that saturates is ~B.
> 
> For ussub, we only have to consider underflow.  The minimum value
> that saturates to 0 from A - B is B.
> 
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   tcg/tcg-op-vec.c | 37 +++++++++++++++++++++++++++++++++++--
>   1 file changed, 35 insertions(+), 2 deletions(-)
> 
> diff --git a/tcg/tcg-op-vec.c b/tcg/tcg-op-vec.c
> index 15e026ae49..7705a49c0b 100644
> --- a/tcg/tcg-op-vec.c
> +++ b/tcg/tcg-op-vec.c
> @@ -119,6 +119,18 @@ bool tcg_can_emit_vecop_list(const TCGOpcode *list,
>                   continue;
>               }
>               break;
> +        case INDEX_op_usadd_vec:
> +            if (tcg_can_emit_vec_op(INDEX_op_umin_vec, type, vece) ||
> +                tcg_can_emit_vec_op(INDEX_op_cmp_vec, type, vece)) {
> +                continue;
> +            }
> +            break;
> +        case INDEX_op_ussub_vec:
> +            if (tcg_can_emit_vec_op(INDEX_op_umax_vec, type, vece) ||
> +                tcg_can_emit_vec_op(INDEX_op_cmp_vec, type, vece)) {
> +                continue;
> +            }
> +            break;
>           case INDEX_op_cmpsel_vec:
>           case INDEX_op_smin_vec:
>           case INDEX_op_smax_vec:
> @@ -603,7 +615,18 @@ void tcg_gen_ssadd_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b)
> 
>   void tcg_gen_usadd_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b)
>   {
> -    do_op3_nofail(vece, r, a, b, INDEX_op_usadd_vec);
> +    if (!do_op3(vece, r, a, b, INDEX_op_usadd_vec)) {
> +        const TCGOpcode *hold_list = tcg_swap_vecop_list(NULL);
> +        TCGv_vec t = tcg_temp_new_vec_matching(r);
> +
> +        /* usadd(a, b) = min(a, ~b) + b */
> +        tcg_gen_not_vec(vece, t, b);
> +        tcg_gen_umin_vec(vece, t, t, a);
> +        tcg_gen_add_vec(vece, r, r, b);

I think it should be

tcg_gen_add_vec(vece, r, t, b);

> +
> +        tcg_temp_free_vec(t);
> +        tcg_swap_vecop_list(hold_list);
> +    }
>   }
> 
>   void tcg_gen_sssub_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b)
> @@ -613,7 +636,17 @@ void tcg_gen_sssub_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b)
> 
>   void tcg_gen_ussub_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b)
>   {
> -    do_op3_nofail(vece, r, a, b, INDEX_op_ussub_vec);
> +    if (!do_op3(vece, r, a, b, INDEX_op_ussub_vec)) {
> +        const TCGOpcode *hold_list = tcg_swap_vecop_list(NULL);
> +        TCGv_vec t = tcg_temp_new_vec_matching(r);
> +
> +        /* ussub(a, b) = max(a, b) - b */
> +        tcg_gen_umax_vec(vece, t, a, b);
> +        tcg_gen_sub_vec(vece, r, t, b);
> +
> +        tcg_temp_free_vec(t);
> +        tcg_swap_vecop_list(hold_list);
> +    }
>   }
> 
>   static void do_minmax(unsigned vece, TCGv_vec r, TCGv_vec a,
> --
> 2.25.1
> 
> 


Thanks,
Matheus K. Ferst
Instituto de Pesquisas ELDORADO <http://www.eldorado.org.br/>
Analista de Software Júnior
Aviso Legal - Disclaimer <https://www.eldorado.org.br/disclaimer.html>


  reply	other threads:[~2021-09-17 11:29 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-15 21:30 [PATCH v5 00/16] tcg/s390x: host vector support Richard Henderson
2021-09-15 21:30 ` [PATCH v5 01/16] tcg: Expand usadd/ussub with umin/umax Richard Henderson
2021-09-17 11:24   ` Matheus K. Ferst [this message]
2021-09-17 13:46     ` Richard Henderson
2021-09-15 21:31 ` [PATCH v5 02/16] tcg/s390x: Rename from tcg/s390 Richard Henderson
2021-09-16  5:19   ` Thomas Huth
2021-09-16  5:27   ` Philippe Mathieu-Daudé
2021-09-15 21:31 ` [PATCH v5 03/16] tcg/s390x: Change FACILITY representation Richard Henderson
2021-09-15 21:31 ` [PATCH v5 04/16] tcg/s390x: Merge TCG_AREG0 and TCG_REG_CALL_STACK into TCGReg Richard Henderson
2021-09-15 21:31 ` [PATCH v5 05/16] tcg/s390x: Add host vector framework Richard Henderson
2021-09-15 21:31 ` [PATCH v5 06/16] tcg/s390x: Implement tcg_out_ld/st for vector types Richard Henderson
2021-09-16  8:09   ` David Hildenbrand
2021-09-15 21:31 ` [PATCH v5 07/16] tcg/s390x: Implement tcg_out_mov " Richard Henderson
2021-09-15 21:31 ` [PATCH v5 08/16] tcg/s390x: Implement tcg_out_dup*_vec Richard Henderson
2021-09-15 21:31 ` [PATCH v5 09/16] tcg/s390x: Implement minimal vector operations Richard Henderson
2021-09-15 21:31 ` [PATCH v5 10/16] tcg/s390x: Implement andc, orc, abs, neg, not " Richard Henderson
2021-09-16  8:12   ` David Hildenbrand
2021-09-15 21:31 ` [PATCH v5 11/16] tcg/s390x: Implement TCG_TARGET_HAS_mul_vec Richard Henderson
2021-09-15 21:31 ` [PATCH v5 12/16] tcg/s390x: Implement vector shift operations Richard Henderson
2021-09-15 21:31 ` [PATCH v5 13/16] tcg/s390x: Implement TCG_TARGET_HAS_minmax_vec Richard Henderson
2021-09-15 21:31 ` [PATCH v5 14/16] tcg/s390x: Implement TCG_TARGET_HAS_sat_vec Richard Henderson
2021-09-15 21:31 ` [PATCH v5 15/16] tcg/s390x: Implement TCG_TARGET_HAS_bitsel_vec Richard Henderson
2021-09-15 21:31 ` [PATCH v5 16/16] tcg/s390x: Implement TCG_TARGET_HAS_cmpsel_vec Richard Henderson

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=d5d876e5-e22b-290c-1510-3c77cc29f357@eldorado.org.br \
    --to=matheus.ferst@eldorado.org.br \
    --cc=david@redhat.com \
    --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.