Message ID | 20230210224150.2801962-2-philipp.tomsich@vrull.eu |
---|---|
State | Under Review |
Delegated to: | Jeff Law |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8BCC338493FF for <patchwork@sourceware.org>; Fri, 10 Feb 2023 22:42:15 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by sourceware.org (Postfix) with ESMTPS id 8A2B2385841A for <gcc-patches@gcc.gnu.org>; Fri, 10 Feb 2023 22:41:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8A2B2385841A 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-x630.google.com with SMTP id p26so19418996ejx.13 for <gcc-patches@gcc.gnu.org>; Fri, 10 Feb 2023 14:41:56 -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:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/RyF/ntVgtCsYGnLFAVrw88rDa/CLJQ3LoKqFAtSIBc=; b=RpqyzydxQ1K+Kk+VpZq4mjbBW0X5IW5t/4/mnS0O7vtMohsquNe8bJ4YoGZksDDhIK W6Qj5arzulxX4Kg9YTh2iakz5HqGR2qSUB8oJvD04l5W3M8AvGyc+NFDJeUtDj8sJ9t+ aMt/7OkqE2SV95nY3e7qdHOP7DClx6ZZX8y0DLfhVvbauylCqjm9YY7dFoMIgQvBC8KI ZuFSw8AFY7iuokIQikpMJjNIhAJDrUHWwlDqIYJW4d6UmlEIZDEa8Y6U3WpxVcOJeWM6 ChrUy6/wnCQ58mb5Zq/a87v/5NjuTS1sSvZtonXn7yg3X2SIHUWekiXaloI2670XiZu3 pMTw== 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:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/RyF/ntVgtCsYGnLFAVrw88rDa/CLJQ3LoKqFAtSIBc=; b=Tx/LT3145RrNzmU8CiO0WhqhBJtHF5an1eCRpYRvsmg/mIOK2rZ6KhCIpf3Njn9he3 qdORVi8KlkvlI88IohEKzP6vay4DTQcbC7OG3e8bJ8v7Mbk98qeUSRMwZpw0fUvB8xAo AUvV1lMZGwTPSzjnAKPkVDjrJf3AGXkwxfQ7lbcvLK5mmoLv/tooaT/UO201emjC9j3j ko/vulWtokpCVeImk7sMe1m5/wWhEDpKULqMCFbW0WBUNt6wuXgSxsHQ7SvRMJy2MQpZ qkWRAEh5pU16/WotnndQvu/2uEgstxFs+VrsjpYvsgraTNIPZuFvVrn+20usZMbCZVc2 CaXg== X-Gm-Message-State: AO0yUKUZeRWmNjEhKKqST60hvUcwMHHRUVDtUGxc2tN2cdY2fjvTYL/3 tfBIxKaTbGaAiE9NWvi/4sMcLYdsEwAlB8TmSl8= X-Google-Smtp-Source: AK7set9f9uRvlbM1duYYPMxG9O88K510A+L6wJOSzLLGCrUAd7lxhRM3X5nBX+w9lDgJnZzzqhvf0w== X-Received: by 2002:a17:907:988e:b0:884:fdb:6c41 with SMTP id ja14-20020a170907988e00b008840fdb6c41mr18384367ejc.43.1676068914991; Fri, 10 Feb 2023 14:41:54 -0800 (PST) Received: from ubuntu-focal.. ([2a01:4f9:3a:1e26::2]) by smtp.gmail.com with ESMTPSA id c15-20020a17090603cf00b0088bd62b1cbbsm2976956eja.192.2023.02.10.14.41.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Feb 2023 14:41:54 -0800 (PST) From: Philipp Tomsich <philipp.tomsich@vrull.eu> To: gcc-patches@gcc.gnu.org Cc: Kito Cheng <kito.cheng@gmail.com>, Christoph Muellner <christoph.muellner@vrull.eu>, Palmer Dabbelt <palmer@rivosinc.com>, Andrew Waterman <andrew@sifive.com>, Vineet Gupta <vineetg@rivosinc.com>, Philipp Tomsich <philipp.tomsich@vrull.eu> Subject: [RFC PATCH v1 01/10] docs: Document a canonical RTL for a conditional-zero insns Date: Fri, 10 Feb 2023 23:41:41 +0100 Message-Id: <20230210224150.2801962-2-philipp.tomsich@vrull.eu> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230210224150.2801962-1-philipp.tomsich@vrull.eu> References: <20230210224150.2801962-1-philipp.tomsich@vrull.eu> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, JMQ_SPF_NEUTRAL, 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
RISC-V: Support the Zicond (conditional-operations) extension
|
|
Commit Message
Philipp Tomsich
Feb. 10, 2023, 10:41 p.m. UTC
On RISC-V, conditional-zero (i.e., move a register value or zero to a
destination register) instructions are part if the Zicond extension.
To support architectures that have similar constructs, we define a
canonical RTL representation that can be used in if-conversion.
Signed-off-by: Philipp Tomsich <philipp.tomsich@vrull.eu>
---
gcc/doc/md.texi | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
Comments
On Fri, Feb 10, 2023 at 2:43 PM Philipp Tomsich <philipp.tomsich@vrull.eu> wrote: > > On RISC-V, conditional-zero (i.e., move a register value or zero to a > destination register) instructions are part if the Zicond extension. > To support architectures that have similar constructs, we define a > canonical RTL representation that can be used in if-conversion. This is seems like worse canonical form than say: (define_insn "" [(set (match_operand:m 0 ...) (if_then_else (eq_or_ne (match_operand:m 1 ...) (const_int 0)) (match_operand:m 2 ...) (const_int 0) ))] "..." "...") (define_insn "" [(set (match_operand:m 0 ...) (if_then_else (eq_or_ne (match_operand:m 1 ...) (const_int 0)) (const_int 0) (match_operand:m 2 ...) ))] "..." "...") Why can't you use the above form instead? This is the standard way of expressing condition moves of 0. This matches even what aarch64 form is already: (define_insn "*cmov<mode>_insn" [(set (match_operand:ALLI 0 "register_operand" "=r,r,r,r,r,r,r") (if_then_else:ALLI (match_operator 1 "aarch64_comparison_operator" [(match_operand 2 "cc_register" "") (const_int 0)]) (match_operand:ALLI 3 "aarch64_reg_zero_or_m1_or_1" "rZ,rZ,UsM,rZ,Ui1,UsM,Ui1") (match_operand:ALLI 4 "aarch64_reg_zero_or_m1_or_1" "rZ,UsM,rZ,Ui1,rZ,UsM,Ui1")))] "!((operands[3] == const1_rtx && operands[4] == constm1_rtx) || (operands[3] == constm1_rtx && operands[4] == const1_rtx))" ;; Final two alternatives should be unreachable, but included for completeness "..." [(set_attr "type" "csel, csel, csel, csel, csel, mov_imm, mov_imm")] ) (Which is more complex as it can handle even more than just the simple case you provide). Thanks, Andrew Pinski > +(define_insn "" > + [(set (match_operand:@var{m} 0 @dots{}) > + (and:@var{m} > + (neg:@var{m} (@var{eq_or_ne} (match_operand:@var{m} 1 @dots{}) > + (const_int 0))) > + (match_operand:@var{m} 2 @dots{})))] > + "@dots{}" > + "@dots{}") > > Signed-off-by: Philipp Tomsich <philipp.tomsich@vrull.eu> > --- > > gcc/doc/md.texi | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > diff --git a/gcc/doc/md.texi b/gcc/doc/md.texi > index 7235d34c4b3..579462ea67f 100644 > --- a/gcc/doc/md.texi > +++ b/gcc/doc/md.texi > @@ -8347,6 +8347,23 @@ operand of @code{mult} is also a shift, then that is extended also. > This transformation is only applied when it can be proven that the > original operation had sufficient precision to prevent overflow. > > +@cindex @code{conditional-zero}, canonicalization of > +@item > +A machine that has an instruction that performs a conditional-zero > +operation (i.e., an instruction that moves a register value or puts 0 > +into the destination register) should specify the pattern for that > +instruction as: > +@smallexample > +(define_insn "" > + [(set (match_operand:@var{m} 0 @dots{}) > + (and:@var{m} > + (neg:@var{m} (@var{eq_or_ne} (match_operand:@var{m} 1 @dots{}) > + (const_int 0))) > + (match_operand:@var{m} 2 @dots{})))] > + "@dots{}" > + "@dots{}") > +@end smallexample > + > @end itemize > > Further canonicalization rules are defined in the function > -- > 2.34.1 >
diff --git a/gcc/doc/md.texi b/gcc/doc/md.texi index 7235d34c4b3..579462ea67f 100644 --- a/gcc/doc/md.texi +++ b/gcc/doc/md.texi @@ -8347,6 +8347,23 @@ operand of @code{mult} is also a shift, then that is extended also. This transformation is only applied when it can be proven that the original operation had sufficient precision to prevent overflow. +@cindex @code{conditional-zero}, canonicalization of +@item +A machine that has an instruction that performs a conditional-zero +operation (i.e., an instruction that moves a register value or puts 0 +into the destination register) should specify the pattern for that +instruction as: +@smallexample +(define_insn "" + [(set (match_operand:@var{m} 0 @dots{}) + (and:@var{m} + (neg:@var{m} (@var{eq_or_ne} (match_operand:@var{m} 1 @dots{}) + (const_int 0))) + (match_operand:@var{m} 2 @dots{})))] + "@dots{}" + "@dots{}") +@end smallexample + @end itemize Further canonicalization rules are defined in the function