From patchwork Thu Mar 3 20:59:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 547839 Delivered-To: patch@linaro.org Received: by 2002:ac0:f585:0:0:0:0:0 with SMTP id s5csp990900imq; Thu, 3 Mar 2022 13:21:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJwIZmNG3PO4sUXABcqyjgn2ur9pxxEmpF4gXCBMnGauJTy16wEc0L4wdc/bOYcvVDXgDsKD X-Received: by 2002:a0d:e2c9:0:b0:2dc:1f22:e349 with SMTP id l192-20020a0de2c9000000b002dc1f22e349mr8493004ywe.10.1646342519290; Thu, 03 Mar 2022 13:21:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646342519; cv=none; d=google.com; s=arc-20160816; b=bbxX7VQmJDBQfoqtU77oq2y2m6wU+m8W4oS1XJLhSCGVWAdy2MBB9bRRxzzJ58B9ZM rphJAjsNMf9xX+vup5SO5mBFqdWx5hnIjaOyM1rJMTFlXdb82O9xVTXynre9RyqaKNjs 4eRUzR0LVOCBs/6avC2WzQlri0H4DSCko3vAmCq+biH9oaUrAgcoOtaC/VmUmXpxoOMw vf/FNIdbSWm/9t6EJjFQ172xgQAKMsW5Ak2g1kK3gxa/Ixzg2bgmwlWqf7vyo2gltoyv R0qGy9JxYdz/X166rhDJ3B/Vk4PrpxANg4V4NxtXdscSTgr1r+YU/vGmL4k9hmXfKEkX 4r/w== 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=1c1ppA+8RTch2imfz9xAE3XksAhgAsrDZznz0cROn8M=; b=A5PM7FLw6AaugYbvE5dkN2vKXQargbdtJBlXfIBs6Pc4HhhCxD5x/gdd2TQJob8k12 G04CrCH+IHIaPJGlG+jIsiKz9GJaLVO9azzJLrE1rTE9fWBaEaW2qCn7bQhOB50YGoBE brKsKbyjbXYjHRnkXLd//fVne6q7O0rXAflYd4ls5LOypkP0Og+IgIJCX5EDeOhSguI1 S4zg23W3BC9LupRuk+f6sczdg1mYRujyWs4kQhBrsGiue2D2vjTX59kJiDwIMMmrZeAP NflZYsmPJxq4KHgtGKFMtwYT8aXPKS6xtlUN4kxAPYjDsDCRM3SCdd35hiifnq6lYz1w +Yhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oDmuIBNW; 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 w11-20020a25df0b000000b00628943cdfa3si2764954ybg.519.2022.03.03.13.21.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 03 Mar 2022 13:21:59 -0800 (PST) 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=oDmuIBNW; 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]:59326 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPsta-0006VP-P2 for patch@linaro.org; Thu, 03 Mar 2022 16:21:58 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59204) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPsYn-00067q-K9 for qemu-devel@nongnu.org; Thu, 03 Mar 2022 16:00:32 -0500 Received: from [2607:f8b0:4864:20::62a] (port=33652 helo=mail-pl1-x62a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nPsYd-0004Ja-B4 for qemu-devel@nongnu.org; Thu, 03 Mar 2022 16:00:20 -0500 Received: by mail-pl1-x62a.google.com with SMTP id c9so5908549pll.0 for ; Thu, 03 Mar 2022 13:00:17 -0800 (PST) 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=1c1ppA+8RTch2imfz9xAE3XksAhgAsrDZznz0cROn8M=; b=oDmuIBNWwr7pgimqhUvrsQznbbQE3fHUq/mvzOdgj0hssV2cau+Mi6XBv5b4jzjAiz VSEiCk4A1S+RAuiXREa1O1ZbZOMgdngDIm9vC5LTGps3JqzKZzq8Gwd1xDdQ2bypgxy2 QQfRPz3oc8ChZMbjKCSu3xT5+1rMo2oUS/XBBVfo8O3JCljzO+iFT30i5fdcXfn+JWgv rCuOvc12k79aFOILKd48SwNuMRM5ybCL1gkWAD2mMjx8S4yp+E29A2Brb6VBDMxPzIey 9oYgruJ24R+aEQGzu4J4IuITNv0q59NWM4bwgMTqXzoQyPG6qCxa+ETPmViF4aYqndCS Ijbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1c1ppA+8RTch2imfz9xAE3XksAhgAsrDZznz0cROn8M=; b=Kq/8glpU6texgxP57tp4Zk7rnaGABvHaCVOrp0pvY3hAiMrAN4cGjhiUmwysnXflxs Ka9ldSnYz5Je6hK1JbU2uHSp+Sr5+Yv2m+HJISrezErJovCn1OIHbWjTB8Ja2v7FpIN7 bR1qvKPHFwh7FTIEGt2ObFJJ9gii3V3mgTfDwHwnxXfSQG9nnCzBvW2cYPSPE2ELGcm0 B+z0Rph+w3lSxRClkIrM3zrPEd/fTBsS9lwmAuli40NJD2P+hC96hsvipY8tp9dDjEsY lA6KEiNUuF9V/4+p8rvLReZWW5e97ueOO6nJvME4XrClkJa48ewWgl6CD+c26MHel4ix rrtg== X-Gm-Message-State: AOAM5328A4a9+716u0O5aTaiwm1AjFcdZEhbO2/84SiVhLiDwRYdKpHd Ef8hnL/mnUbwDkH9DtCLU51FdUMOW+J9bw== X-Received: by 2002:a17:902:7610:b0:151:6152:549c with SMTP id k16-20020a170902761000b001516152549cmr24228368pll.91.1646341217104; Thu, 03 Mar 2022 13:00:17 -0800 (PST) Received: from localhost.localdomain (2603-800c-1201-c600-119c-490c-a4ee-08e8.res6.spectrum.com. [2603:800c:1201:c600:119c:490c:a4ee:8e8]) by smtp.gmail.com with ESMTPSA id t8-20020a6549c8000000b00372eb3a7fb3sm2729934pgs.92.2022.03.03.13.00.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 13:00:16 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 20/30] tcg/i386: Implement more logical operations for avx512 Date: Thu, 3 Mar 2022 10:59:34 -1000 Message-Id: <20220303205944.469445-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220303205944.469445-1-richard.henderson@linaro.org> References: <20220303205944.469445-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::62a (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" AVX512VL has a general ternary logic operation, VPTERNLOGQ, which can implement NOT, ORC, NAND, NOR, EQV. Tested-by: Alex Bennée Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- tcg/i386/tcg-target.h | 10 +++++----- tcg/i386/tcg-target.c.inc | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h index da1eff59aa..e02cef7575 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -188,11 +188,11 @@ extern bool have_movbe; #define TCG_TARGET_HAS_v256 have_avx2 #define TCG_TARGET_HAS_andc_vec 1 -#define TCG_TARGET_HAS_orc_vec 0 -#define TCG_TARGET_HAS_nand_vec 0 -#define TCG_TARGET_HAS_nor_vec 0 -#define TCG_TARGET_HAS_eqv_vec 0 -#define TCG_TARGET_HAS_not_vec 0 +#define TCG_TARGET_HAS_orc_vec have_avx512vl +#define TCG_TARGET_HAS_nand_vec have_avx512vl +#define TCG_TARGET_HAS_nor_vec have_avx512vl +#define TCG_TARGET_HAS_eqv_vec have_avx512vl +#define TCG_TARGET_HAS_not_vec have_avx512vl #define TCG_TARGET_HAS_neg_vec 0 #define TCG_TARGET_HAS_abs_vec 1 #define TCG_TARGET_HAS_roti_vec have_avx512vl diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index a800764d2f..140a51ce70 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -448,6 +448,7 @@ static bool tcg_target_const_match(int64_t val, TCGType type, int ct) #define OPC_VPSRLVW (0x10 | P_EXT38 | P_DATA16 | P_VEXW | P_EVEX) #define OPC_VPSRLVD (0x45 | P_EXT38 | P_DATA16) #define OPC_VPSRLVQ (0x45 | P_EXT38 | P_DATA16 | P_VEXW) +#define OPC_VPTERNLOGQ (0x25 | P_EXT3A | P_DATA16 | P_VEXW | P_EVEX) #define OPC_VZEROUPPER (0x77 | P_EXT) #define OPC_XCHG_ax_r32 (0x90) @@ -3098,6 +3099,29 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, insn = vpshldi_insn[vece]; sub = args[3]; goto gen_simd_imm8; + + case INDEX_op_not_vec: + insn = OPC_VPTERNLOGQ; + a2 = a1; + sub = 0x33; /* !B */ + goto gen_simd_imm8; + case INDEX_op_nor_vec: + insn = OPC_VPTERNLOGQ; + sub = 0x11; /* norCB */ + goto gen_simd_imm8; + case INDEX_op_nand_vec: + insn = OPC_VPTERNLOGQ; + sub = 0x77; /* nandCB */ + goto gen_simd_imm8; + case INDEX_op_eqv_vec: + insn = OPC_VPTERNLOGQ; + sub = 0x99; /* xnorCB */ + goto gen_simd_imm8; + case INDEX_op_orc_vec: + insn = OPC_VPTERNLOGQ; + sub = 0xdd; /* orB!C */ + goto gen_simd_imm8; + gen_simd_imm8: tcg_debug_assert(insn != OPC_UD2); if (type == TCG_TYPE_V256) { @@ -3318,6 +3342,10 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_or_vec: case INDEX_op_xor_vec: case INDEX_op_andc_vec: + case INDEX_op_orc_vec: + case INDEX_op_nand_vec: + case INDEX_op_nor_vec: + case INDEX_op_eqv_vec: case INDEX_op_ssadd_vec: case INDEX_op_usadd_vec: case INDEX_op_sssub_vec: @@ -3350,6 +3378,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_abs_vec: case INDEX_op_dup_vec: + case INDEX_op_not_vec: case INDEX_op_shli_vec: case INDEX_op_shri_vec: case INDEX_op_sari_vec: @@ -3378,6 +3407,11 @@ int tcg_can_emit_vec_op(TCGOpcode opc, TCGType type, unsigned vece) case INDEX_op_or_vec: case INDEX_op_xor_vec: case INDEX_op_andc_vec: + case INDEX_op_orc_vec: + case INDEX_op_nand_vec: + case INDEX_op_nor_vec: + case INDEX_op_eqv_vec: + case INDEX_op_not_vec: return 1; case INDEX_op_cmp_vec: case INDEX_op_cmpsel_vec: