From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ua1-x934.google.com (mail-ua1-x934.google.com [IPv6:2607:f8b0:4864:20::934]) by sourceware.org (Postfix) with ESMTPS id 21EE83858D37 for ; Fri, 28 Apr 2023 07:22:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 21EE83858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ua1-x934.google.com with SMTP id a1e0cc1a2514c-77aad9ef9adso7806543241.1 for ; Fri, 28 Apr 2023 00:22:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682666519; x=1685258519; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Iw6benboemkY3lzWvFHCiwjn7eyAZeiXLXKUveLtlvY=; b=Ec382dZtwNwbudva/Atdl/Zd+lZ/Qr7LpNjn9z870P4msiB2IiojS5G+A9jPKw17Z+ IbrJLXiedW4PO9rbNfocpMnQKRDVAV63e1eNeE4SmhaLU5VKJYG2r02qe9zRJLyzaTaT eo3iQ+Bs/59+J0V+q8kDVeySWFZjVitbaCjJfPfREy4XqJTO2hwmPtlj8kbzLol+l57w u9kU+m6loF3Q9NtIpRmSylmuywTOzGJBBrjIdYa3IXr4DZDE3ihlBYoF2HRfPMfHDnYt Qhv5hZIVN5uScEqhyk2NBAHqpOpwrwtyvBmJMAqcRbe3HHK+CNwiQ9Bc6YiJZcWyv1Vv PQ4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682666519; x=1685258519; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Iw6benboemkY3lzWvFHCiwjn7eyAZeiXLXKUveLtlvY=; b=hHWo/FI1EHxTeNfnb0nbTMLGZJ5Nncv5Z/TrRr6u0Y8Iq8hdl5E/R9cJr4AgbjSZC8 gBvWwjaPbyiNRB+X4ZNsMyfAC4d3WwJF1eNcYeOl8J4gXhLk4ByqKh5GPgXCD9vM+rjd +0W2Fupw5I4Np25l6rBXidVYAy+qeMZK00SZmTZsC0ZxIlPnh+bOQP1ZSUvWPd4azvAn pDpezRRJiijsXO3vMASBANhIWpUlTdXkOJYuDynNB1StSXhbPXlNwcu9D7BrrRKQT6JA D1vqKnhcCPPvWhgkbEl8JGRFboV9FBlMk3B0oGJxs1I9xngQK0l3JOgs5Ufuh2XB2iWP 9pKg== X-Gm-Message-State: AC+VfDwKja3hyucnOAL3VuY7o8TkvjMmp48upcpQaGiz3n8JjdXQo0Vj qlV7wPEB93alZ43dFF3uHMwfOBxRjMERmt6uWnI= X-Google-Smtp-Source: ACHHUZ5QacuyWt7UcIyFymP+T4qePtMmmtp96A/iS7EdQpv+CL1mvqJVoa5CnaVg+q0bysjdkYxlGRxPYiQH+WEcdi4= X-Received: by 2002:a1f:c642:0:b0:401:6b30:5eef with SMTP id w63-20020a1fc642000000b004016b305eefmr1719928vkf.8.1682666519309; Fri, 28 Apr 2023 00:21:59 -0700 (PDT) MIME-Version: 1.0 References: <20230428061210.2988035-1-christoph.muellner@vrull.eu> <20230428061210.2988035-6-christoph.muellner@vrull.eu> In-Reply-To: <20230428061210.2988035-6-christoph.muellner@vrull.eu> From: Kito Cheng Date: Fri, 28 Apr 2023 15:21:48 +0800 Message-ID: Subject: Re: [PATCH 05/11] riscv: Simplify output of MEM addresses To: Christoph Muellner Cc: gcc-patches@gcc.gnu.org, Kito Cheng , Jim Wilson , Palmer Dabbelt , Andrew Waterman , Philipp Tomsich , Cooper Qu , Lifang Xia , Yunhai Shang , Zhiwei Liu Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: LGTM, thanks :) On Fri, Apr 28, 2023 at 2:13=E2=80=AFPM Christoph Muellner wrote: > > From: Christoph M=C3=BCllner > > We have the following situation for MEM RTX objects: > * TARGET_PRINT_OPERAND expands to riscv_print_operand() > * This falls into the default case (unknown or on letter) of the outer > switch-case-block and the MEM case of the inner switch-case-block and > calls output_address() in final.cc with XEXP (op, 0) (the address) > * This calls targetm.asm_out.print_operand_address() which is > riscv_print_operand_address() > * riscv_print_operand_address() is targeting the address of a MEM RTX > * riscv_print_operand_address() calls riscv_print_operand() for the offse= t > and directly prints the register if the address is classified as ADDRES= S_REG > * This falls into the default case (unknown or on letter) of the outer > switch-case-block and the default case of the inner switch-case-block a= nd > calls output_addr_const(). > > However, since we know that offset must be a CONST_INT (which will be > followed by a '()' string), there is no need to call > riscv_print_operand() for the offset. > Instead we can take the shortcut and use output_addr_const(). > > This change also brings the code in riscv_print_operand_address() > in line with the other cases, where output_addr_const() is used > to print offsets. > > Tested with GCC regression test suite and SPEC intrate. > > Signed-off-by: Christoph M=C3=BCllner > --- > gcc/config/riscv/riscv.cc | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc > index 5d2550871c7..92043236b17 100644 > --- a/gcc/config/riscv/riscv.cc > +++ b/gcc/config/riscv/riscv.cc > @@ -4581,7 +4581,7 @@ riscv_print_operand_address (FILE *file, machine_mo= de mode ATTRIBUTE_UNUSED, rtx > switch (addr.type) > { > case ADDRESS_REG: > - riscv_print_operand (file, addr.offset, 0); > + output_addr_const (file, riscv_strip_unspec_address (addr.offset)= ); > fprintf (file, "(%s)", reg_names[REGNO (addr.reg)]); > return; > > -- > 2.40.1 >