From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26DBFC433EF for ; Fri, 17 Sep 2021 11:29:09 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B8312610E9 for ; Fri, 17 Sep 2021 11:29:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B8312610E9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=eldorado.org.br Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:38580 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mRC3H-0000BS-Ou for qemu-devel@archiver.kernel.org; Fri, 17 Sep 2021 07:29:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57358) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mRBz9-0004F7-3b for qemu-devel@nongnu.org; Fri, 17 Sep 2021 07:24:52 -0400 Received: from [201.28.113.2] (port=48354 helo=outlook.eldorado.org.br) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mRBz6-0002HG-Dy for qemu-devel@nongnu.org; Fri, 17 Sep 2021 07:24:50 -0400 Received: from power9a ([10.10.71.235]) by outlook.eldorado.org.br with Microsoft SMTPSVC(8.5.9600.16384); Fri, 17 Sep 2021 08:24:43 -0300 Received: from [127.0.0.1] (unknown [10.10.70.45]) by power9a (Postfix) with ESMTP id C4BB680130D; Fri, 17 Sep 2021 08:24:42 -0300 (-03) Subject: Re: [PATCH v5 01/16] tcg: Expand usadd/ussub with umin/umax To: Richard Henderson , qemu-devel@nongnu.org References: <20210915213114.1923776-1-richard.henderson@linaro.org> <20210915213114.1923776-2-richard.henderson@linaro.org> From: "Matheus K. Ferst" Message-ID: Date: Fri, 17 Sep 2021 08:24:43 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20210915213114.1923776-2-richard.henderson@linaro.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-OriginalArrivalTime: 17 Sep 2021 11:24:43.0185 (UTC) FILETIME=[9CAF4A10:01D7ABB6] X-Host-Lookup-Failed: Reverse DNS lookup failed for 201.28.113.2 (failed) Received-SPF: pass client-ip=201.28.113.2; envelope-from=matheus.ferst@eldorado.org.br; helo=outlook.eldorado.org.br X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_40=-0.001, NICE_REPLY_A=-1.488, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: david@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 > --- > 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 Analista de Software Júnior Aviso Legal - Disclaimer