From patchwork Sat Jun 26 05:03:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 467421 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp2137533jao; Fri, 25 Jun 2021 22:07:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnQ2KjMnje67h8+fUh0i8Pj5v9GB8YPSQoEXkIgXRZ/CXA0Yy8cKuFxlFqgB9ZlngQ0MOF X-Received: by 2002:ae9:f50e:: with SMTP id o14mr15476455qkg.141.1624684024373; Fri, 25 Jun 2021 22:07:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624684024; cv=none; d=google.com; s=arc-20160816; b=jnNy9ZMU3CQ7dOjBtBPqygbHyJSmTUP/L+G37vMeq+C+1JFfKr4Nvt98hW4xRfftxm NIBhPBjMfkptpwIH4ls6IEIfrEYKVkwk9y03P9p3e+ZeZ02KrBHoOuZ95QBNpg9tJipE LhzQqMOAnWc/l59vx3J34GbOzqqxsW9dRaTjVetz/dHsVFuiue3Pr7H+BC7q0oiX4eIu fYFEM9Ebeu16xj0ymT4kFpT7x4wFtf1Jd4x6utJNlSRsgAJrWCupz83idDbPQUV/owUm UdDQH+YwoY7DdZKnOHLxUE94H8DCXBP/6PnRiADKb6L+pjQ3BlRFVavwjZipTJQLIGVa tizQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=lhsY62Axz8P4uEG2iGxE1nxCZRsB4mKyTgfXOvjyYjw=; b=kzhQdzuTqdYMsvQIYVIzkA0fbzJxTajdHSg/5Fod5ye6/39MwyqHDJg9jvfowjCCP1 tb9Axx02ZuE+sPk75zwb9HT/yMGsPO+ZIZJ1uFSSlWsctzYRg4RAIPCKDdfs75+OcRGi O3fr3JcvZT7rvZfRt40oH7KhwoCxI3NbFCtWW0hleSxhfSxbRwuekVN++GcodKDEPKlm Lyj0FFlnIxorYLFpW21L5m5a2SIcq1lxknf/qsP8Emb4voNLuk7F/9EriCco0DBNmlie xAzCBE43nTi9wAYjuOupmBqMUG77VE4tmmFDtv4/VOTIqzGQ0zq1nqYGX7nnCABnCfHk VMGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="a/00Azyr"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 66si6353694qta.25.2021.06.25.22.07.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Jun 2021 22:07:04 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="a/00Azyr"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:53526 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lx0X1-0001SI-Rs for patch@linaro.org; Sat, 26 Jun 2021 01:07:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45198) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lx0TQ-000746-FH for qemu-devel@nongnu.org; Sat, 26 Jun 2021 01:03:20 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]:38639) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lx0TN-0008IL-32 for qemu-devel@nongnu.org; Sat, 26 Jun 2021 01:03:20 -0400 Received: by mail-pf1-x436.google.com with SMTP id c8so9140217pfp.5 for ; Fri, 25 Jun 2021 22:03:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lhsY62Axz8P4uEG2iGxE1nxCZRsB4mKyTgfXOvjyYjw=; b=a/00AzyrKg2sXXifK8rvABidCYpujudF5re+4qmV15W1VkOlaLx9Ipu9IMkEWbpkQ8 somlR2OMZ+QuIr5L/wj/keWRucCNB3S5GqdvxH9SbDoXVQT20m24xyxYbvFs/EHzbUgb u1k8anGncFjHG9AwrW6otl10CohibYn6JlPqeLnyDvHbt7RNURQQKWIsxbx3kA2oyE5N /x/iT1cXlNzjIQVL8iI+d0Y5wf/FfOkHHj6+xyN6iUXbtUzy6Dv2f1NWiyGXVglbx0Tr UdeKdUF2jdyPYW6T/zswPtwIFWeN3FQQ1iTSO5JtsJPZ9/Nh/dITHpMvQP/FH9RQ/C37 /4Fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lhsY62Axz8P4uEG2iGxE1nxCZRsB4mKyTgfXOvjyYjw=; b=RDd9M0cFwVMFmkY1j51vipRygHOyvGcxFjm/xxUw97EZvmQFGF4l88ISkqwQqFG9FY kT2p01M86aIXpRCeKLph2uuNTx+26SY6yUgrwaFVyvw7+uIFe+P8eSmxiNwnTDgB1Nn1 KzjAEjrjJL/oBLCbz53Hc24j3WD94RHPSusg3l0XNUl2jIcW4uT0R6pMvDESNhUkdaMc CbtxsbbIhleqZGZO0k7vYPyRFLRN+f6pZNg5B7aGeb9KlokNw54Vnhz6nLEFQYUWcT+T 7KfQuJAdFHE3t/ovkBD2bpdzyeVLO87rpg5k3ElTuKP+pTSvxfNvOBtJV8JcGALJ6IqH lUzg== X-Gm-Message-State: AOAM531jYfZaxsDCKbQWFhkMZ8rZxkDj17uCTbhpXXWZxFPcaZnXHXAy 4bvAU/ClPbxrBrB676sCIhz2c9b3LAeUUw== X-Received: by 2002:a63:312:: with SMTP id 18mr12892136pgd.33.1624683795797; Fri, 25 Jun 2021 22:03:15 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id c62sm7389768pfa.12.2021.06.25.22.03.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 22:03:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 13/16] tcg: Expand usadd/ussub with umin/umax Date: Fri, 25 Jun 2021 22:03:04 -0700 Message-Id: <20210626050307.2408505-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210626050307.2408505-1-richard.henderson@linaro.org> References: <20210626050307.2408505-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::436; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x436.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.25.1 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); + + 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,