Message ID | 20221113230521.712693-2-christoph.muellner@vrull.eu |
---|---|
State | Accepted |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1865097wru; Sun, 13 Nov 2022 15:07:22 -0800 (PST) X-Google-Smtp-Source: AA0mqf5S0sREybmJoPi8NOZA036JANf50LG3V4NzWsRyzrphfuTNEAraSK/cEQ6DWHCR4FzgR9zQ X-Received: by 2002:a17:906:6592:b0:7ae:9677:d8dd with SMTP id x18-20020a170906659200b007ae9677d8ddmr8623548ejn.71.1668380841944; Sun, 13 Nov 2022 15:07:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668380841; cv=none; d=google.com; s=arc-20160816; b=XlsfWsm5REw4DLUnQHpUe8nGYryCiB6Od5SPF98YHqVyctl/dU0aT36Dele4ogaQQq auv0rH8QJVf8kH7TTaVdOK8d3h4Y163rYdOjhxuf+kR+QcZFk1coYCPKHn8D2OYrXVXu gzCA0ixPRW5k/mZrCcJDg1gu6NXK4T0Tg18w8BcQ4JEWrObvJpBRmO+1aB3Vfn/ph7KQ 2w7OHruSVSm6kVUTMF72gcl35Q8wDBdDXDsTlMXXOxb5zl/Zr6LkWL3EmFnP1wYxLqQ4 aAcm4x9FqgrA/02kdU4k3c3Qe/WN5Q5VBXzQ2W41h7GyrXbiJbbn3QwdZG/iyXY9rA2Z +U7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:dmarc-filter:delivered-to; bh=kDf6CpvIiHTXCKB+bGNFUiN2AZZOL3Lt7/xgFFvIVw0=; b=hcSWsebtlxtFlZJUpazBtfQZ0E0n58yvNqCUtu/QOsRtD8bYl6PqKTFv6PQVKtBOSj ovw/KWw5HAp5KxMCmC+r7/kkYWgjcQVzRSnSqb+pQPc5UPvJT2x4PIKEg3iDDFX6Z7Bv 4m3SojbY5JJqOLcMHzkGZlzZ1GLywSLzUT8SOimR2uVCS6cr9LdraxCGptd/lSBxtfCQ RA7U6xqkvB+rhB1tHyuDWOH+P6gS9JTjBmK07fogPK3u8QipvUJHxhwZECeJb8c2wwKS fnRRF7VHld2xb87weChqiTHQahR6n/GtFBsuIOxSr0DWru4JPC53e0g9t1khXNSJx1Vl uVWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@vrull.eu header.s=google header.b=AiVnnOny; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id wt5-20020a170906ee8500b0073d8830e4c7si7585035ejb.954.2022.11.13.15.07.21 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Nov 2022 15:07:21 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@vrull.eu header.s=google header.b=AiVnnOny; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8C16138AA240 for <ouuuleilei@gmail.com>; Sun, 13 Nov 2022 23:06:11 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by sourceware.org (Postfix) with ESMTPS id 360913857365 for <gcc-patches@gcc.gnu.org>; Sun, 13 Nov 2022 23:05:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 360913857365 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=vrull.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=vrull.eu Received: by mail-ej1-x634.google.com with SMTP id 13so24506685ejn.3 for <gcc-patches@gcc.gnu.org>; Sun, 13 Nov 2022 15:05:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull.eu; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=kDf6CpvIiHTXCKB+bGNFUiN2AZZOL3Lt7/xgFFvIVw0=; b=AiVnnOnyLSOGjL+tkaZIXrr9DNy2Pc7TOlV8P5hmG5SpSMIAep5+sCvMSSIF03e6Ur JdBsd51ttc+z/Wocfux0Z8qdtV74RINtiBiNhYgawDfaosdTNmmXbHBuaB2V0mufE5AR 6l5c60nRH78+MwlE7tNkRQne1VtG7YK6nZ2OKpW6XqRu/k/qpM+SLHpDbbUztgq2AUnd 5/j2jhf6mLcINX80xkCd9sKZ6a99iBR5M/BA2aQp65mUs3AzfAald6x3XpwuvtpF0+JU s2Dc922mCdkuqP6bZGe4TwAuRCxN5A2ccot4GIh+fq5Wo8uYML3a2P6UJHx0x6Y8uwql 5zsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kDf6CpvIiHTXCKB+bGNFUiN2AZZOL3Lt7/xgFFvIVw0=; b=ljWdJSwi6orWywv08mPxw0i59bgNMo3ZuKMSs58NHXFUixcUvAVSR/BStP5SbcyjtW neNwoW2cWQv18WhU2q+YH6KBCwTl44rvMC8uC5epAapXtvW8X6+lDRH9oQ8aIARiYsyn TyWUa+U3v6np8LQZ8LT8Kd+KpjTv6P9oA0fAalekF3A/wS2P84GPTDWh8Y3FphxRKjjC S/IY746MhtGPM3tUSSt1eOY1Lt3lnbDviMNDVz5gmo1E6G5e7dCEoC+ObgGMcDG4+l0G sXq+zEreYcMqN7hVWLviXv23sjPWxX8l66quP3esmO5XhZCJQ5yL3nGtCxgtj5AsFfpO Xb7Q== X-Gm-Message-State: ANoB5pmerw7JC0o4sxvVbz+ANTB1lg6q7UTjcsABhwebhjMqnvkqLus6 fzYzdDr4XPjSWWZHBll9zeUzpf/g6kamjWYR X-Received: by 2002:a17:906:f196:b0:78d:6a9b:216c with SMTP id gs22-20020a170906f19600b0078d6a9b216cmr8542359ejb.602.1668380725766; Sun, 13 Nov 2022 15:05:25 -0800 (PST) Received: from beast.fritz.box (62-178-148-172.cable.dynamic.surfer.at. [62.178.148.172]) by smtp.gmail.com with ESMTPSA id ku3-20020a170907788300b007ae21bbdd3fsm2361281ejc.162.2022.11.13.15.05.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Nov 2022 15:05:25 -0800 (PST) From: Christoph Muellner <christoph.muellner@vrull.eu> To: gcc-patches@gcc.gnu.org, Kito Cheng <kito.cheng@sifive.com>, Jim Wilson <jim.wilson.gcc@gmail.com>, Palmer Dabbelt <palmer@dabbelt.com>, Andrew Waterman <andrew@sifive.com>, Philipp Tomsich <philipp.tomsich@vrull.eu>, Jeff Law <jeffreyalaw@gmail.com>, Vineet Gupta <vineetg@rivosinc.com> Subject: [PATCH 1/7] riscv: bitmanip: add orc.b as an unspec Date: Mon, 14 Nov 2022 00:05:15 +0100 Message-Id: <20221113230521.712693-2-christoph.muellner@vrull.eu> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221113230521.712693-1-christoph.muellner@vrull.eu> References: <20221113230521.712693-1-christoph.muellner@vrull.eu> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_MANYTO, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749424109334225086?= X-GMAIL-MSGID: =?utf-8?q?1749424109334225086?= |
Series |
riscv: Improve builtins expansion
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | success | Github commit url |
Commit Message
Christoph Müllner
Nov. 13, 2022, 11:05 p.m. UTC
From: Philipp Tomsich <philipp.tomsich@vrull.eu> As a basis for optimized string functions (e.g., the by-pieces implementations), we need orc.b available. This adds orc.b as an unspec, so we can expand to it. gcc/ChangeLog: * config/riscv/bitmanip.md (orcb<mode>2): Add orc.b as an unspec. * config/riscv/riscv.md: Add UNSPEC_ORC_B. Signed-off-by: Philipp Tomsich <philipp.tomsich@vrull.eu> --- gcc/config/riscv/bitmanip.md | 8 ++++++++ gcc/config/riscv/riscv.md | 3 +++ 2 files changed, 11 insertions(+)
Comments
On 11/13/22 16:05, Christoph Muellner wrote: > From: Philipp Tomsich <philipp.tomsich@vrull.eu> > > As a basis for optimized string functions (e.g., the by-pieces > implementations), we need orc.b available. This adds orc.b as an > unspec, so we can expand to it. > > gcc/ChangeLog: > > * config/riscv/bitmanip.md (orcb<mode>2): Add orc.b as an > unspec. > * config/riscv/riscv.md: Add UNSPEC_ORC_B. In general, we should prefer to express things as "real" RTL rather than UNSPECS. In this particular case expressing the orc could be done with a handful of IOR expressions, though they'd probably need to reference byte SUBREGs of the input and I dislike explicit SUBREGs in the md file even more than UNSPECs. So.... OK. Jeff ps. We could consider this a reduc_ior_scal insn, but that may be actively harmful. Having vector ops on the general and vector registers is a wart I hope we can avoid.
On 11/14/22 09:51, Jeff Law wrote: > > On 11/13/22 16:05, Christoph Muellner wrote: >> From: Philipp Tomsich <philipp.tomsich@vrull.eu> >> >> As a basis for optimized string functions (e.g., the by-pieces >> implementations), we need orc.b available. This adds orc.b as an >> unspec, so we can expand to it. >> >> gcc/ChangeLog: >> >> * config/riscv/bitmanip.md (orcb<mode>2): Add orc.b as an >> unspec. >> * config/riscv/riscv.md: Add UNSPEC_ORC_B. > In general, we should prefer to express things as "real" RTL rather > than UNSPECS. In this particular case expressing the orc could be > done with a handful of IOR expressions, though they'd probably need to > reference byte SUBREGs of the input and I dislike explicit SUBREGs in > the md file even more than UNSPECs. Mis-read the specs on orc. So ignore the comment about expressing this as a handful of IORs and about it being reduc_ior_scal. jeff
On Mon, 14 Nov 2022 at 17:51, Jeff Law <jeffreyalaw@gmail.com> wrote: > > > On 11/13/22 16:05, Christoph Muellner wrote: > > From: Philipp Tomsich <philipp.tomsich@vrull.eu> > > > > As a basis for optimized string functions (e.g., the by-pieces > > implementations), we need orc.b available. This adds orc.b as an > > unspec, so we can expand to it. > > > > gcc/ChangeLog: > > > > * config/riscv/bitmanip.md (orcb<mode>2): Add orc.b as an > > unspec. > > * config/riscv/riscv.md: Add UNSPEC_ORC_B. > In general, we should prefer to express things as "real" RTL rather than > UNSPECS. In this particular case expressing the orc could be done with > a handful of IOR expressions, though they'd probably need to reference > byte SUBREGs of the input and I dislike explicit SUBREGs in the md file > even more than UNSPECs. So.... > > OK. Applied to master. Thanks! (After using emacs' whitespace-cleanup to fix the damage that Christoph's vim did to the ChangeLog...) Philipp. > > > Jeff > > > ps. We could consider this a reduc_ior_scal insn, but that may be > actively harmful. Having vector ops on the general and vector registers > is a wart I hope we can avoid. > >
diff --git a/gcc/config/riscv/bitmanip.md b/gcc/config/riscv/bitmanip.md index b44fb9517e7..3dbe6002974 100644 --- a/gcc/config/riscv/bitmanip.md +++ b/gcc/config/riscv/bitmanip.md @@ -242,6 +242,14 @@ (define_insn "rotlsi3_sext" "rolw\t%0,%1,%2" [(set_attr "type" "bitmanip")]) +;; orc.b (or-combine) is added as an unspec for the benefit of the support +;; for optimized string functions (such as strcmp). +(define_insn "orcb<mode>2" + [(set (match_operand:X 0 "register_operand" "=r") + (unspec:X [(match_operand:X 1 "register_operand" "r")] UNSPEC_ORC_B))] + "TARGET_ZBB" + "orc.b\t%0,%1") + (define_insn "bswap<mode>2" [(set (match_operand:X 0 "register_operand" "=r") (bswap:X (match_operand:X 1 "register_operand" "r")))] diff --git a/gcc/config/riscv/riscv.md b/gcc/config/riscv/riscv.md index 798f7370a08..532289dd178 100644 --- a/gcc/config/riscv/riscv.md +++ b/gcc/config/riscv/riscv.md @@ -62,6 +62,9 @@ (define_c_enum "unspec" [ ;; Stack tie UNSPEC_TIE + + ;; OR-COMBINE + UNSPEC_ORC_B ]) (define_c_enum "unspecv" [