From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by sourceware.org (Postfix) with ESMTPS id 22B1B3858D20; Tue, 13 Jun 2023 00:24:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 22B1B3858D20 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-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-51493ec65d8so8673957a12.2; Mon, 12 Jun 2023 17:24:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686615876; x=1689207876; 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=EKpfaIl2ykWAETMCJQuLCK1cSCJM5rFKSZv9U7ERWGk=; b=iHnaXN3VFsvhWzORu3h6W8SoRBWDg2jR3Cq5Jp3ySrvUMN+wEtgn8SkT30rb8F0z6D RTMNejpgDTXt8ORRAK4SPcdJ/a27D8XZ1lMtpV2zBGPDH1rrdSkc5hNaT+RDgZ/VWFtc 6Ilgsub9Rb4Rj6AQfNfoKAxnOrRqb6H39ZK6Q4Ct32GYReInTHAoHoNhE0NPZxq2hYvx iMK/c0Axxg+l1mVpijSHJZ/0ALMJAM6GGoeGerIJ85dVOxdfrOAneK81GL3eBBVDaCdt b1q6GmDbMnEppXFTSWnzK6i/q5rTQFqb+YcDlp8xMfqxOZoWO9ixjAa7a/auYBSjxzLb 66KA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686615876; x=1689207876; 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=EKpfaIl2ykWAETMCJQuLCK1cSCJM5rFKSZv9U7ERWGk=; b=DMSYHsUEc462KNW6c83f/2L1VaRhkabQj/dBeRrpqrEyROnPr718jHf+//YtnfKfLa /OtuRSvN83cC8TBNo2Fs69nBxAF3US8EaQcQLhU62cxyuhNieUamMrAjE3G8p9l8GNPJ 7VCuiaDYGiVmzeORmolXYALVG+YxpMNsgC7rBO2dfB+Os3+G0LKJ1dBfqmMaW7mnbhcY ppfCJUfSelJRHYb+izClDbqBs7lM7ye2F8Tm1PEgPuKYzZ/zrbQkrT42FmK2clbDQLk3 +ulLnCM4x1dBqRgmZoG/tu/xxVsxONVowLmCd/bXWqFfkMKfnaA0bXXqV5JH/QIEhaI0 3I6w== X-Gm-Message-State: AC+VfDzvq2/zQyYvFfu4hIJE+MnydY8yNfa5udphdqVPQDtydVvTFX0k ELI81rTlwzjU7tWWoWYlvWxOPsje7EvCDt3LzwI= X-Google-Smtp-Source: ACHHUZ6RxDdH8E0b1aDfWPzS5rBlpBu3MwtFRmUZbLy1rFeTGSD9euMHPJB1h/b8VyKoU5WkWeU8sIOXohT/0uZKG78= X-Received: by 2002:a17:907:c15:b0:94e:48ac:9a51 with SMTP id ga21-20020a1709070c1500b0094e48ac9a51mr11532823ejc.4.1686615875584; Mon, 12 Jun 2023 17:24:35 -0700 (PDT) MIME-Version: 1.0 References: <20230612131919.269681-1-guojiufu@linux.ibm.com> In-Reply-To: <20230612131919.269681-1-guojiufu@linux.ibm.com> From: David Edelsohn Date: Mon, 12 Jun 2023 20:24:24 -0400 Message-ID: Subject: Re: [PATCH] rs6000: replace '(const_int 0)' to 'unspec:BLK [(const_int 0)]' for stack_tie To: Jiufu Guo Cc: gcc-patches@gcc.gnu.org, segher@kernel.crashing.org, linkw@gcc.gnu.org, bergner@linux.ibm.com, rguenther@suse.de, richard.sandiford@arm.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.1 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: Hi, Jiufu This definitely seems to be a better solution. The TARGET_CONST_ANCHOR change should not be part of this patch. Also there is no ChangeLog for the patch. This generally looks correct and consistent with other ports. I want to give Segher a chance to double check it, if he wishes. Thanks David On Mon, Jun 12, 2023 at 9:19=E2=80=AFAM Jiufu Guo = wrote: > > Hi, > > For stack_tie, currently below insn is generated: > (insn 15 14 16 3 (parallel [ > (set (mem/c:BLK (reg/f:DI 1 1) [1 A8]) > (const_int 0 [0])) > ]) "/home/guojiufu/temp/gdb.c":13:3 922 {stack_tie} > (nil)) > > It is "set (mem/c:BLK (reg/f:DI 1 1) (const_int 0 [0])". This maybe > looks like "a memory block is zerored", while actually stack_tie > may be more like a placeholder, and does not generate any thing. > > To avoid potential misunderstand, "UNPSEC:BLK [(const_int 0)].." could > be used here like other ports. > > This patch does this. Bootstrap®test pass on ppc64{,le}. > Is this ok for trunk? > > BR, > Jeff (Jiufu Guo) > > --- > gcc/config/rs6000/predicates.md | 11 +++++++---- > gcc/config/rs6000/rs6000-logue.cc | 4 +++- > gcc/config/rs6000/rs6000.cc | 4 ++++ > gcc/config/rs6000/rs6000.md | 14 ++++++++++---- > 4 files changed, 24 insertions(+), 9 deletions(-) > > diff --git a/gcc/config/rs6000/predicates.md b/gcc/config/rs6000/predicat= es.md > index a16ee30f0c0..4748cb37ce8 100644 > --- a/gcc/config/rs6000/predicates.md > +++ b/gcc/config/rs6000/predicates.md > @@ -1854,10 +1854,13 @@ (define_predicate "stmw_operation" > (define_predicate "tie_operand" > (match_code "parallel") > { > - return (GET_CODE (XVECEXP (op, 0, 0)) =3D=3D SET > - && MEM_P (XEXP (XVECEXP (op, 0, 0), 0)) > - && GET_MODE (XEXP (XVECEXP (op, 0, 0), 0)) =3D=3D BLKmode > - && XEXP (XVECEXP (op, 0, 0), 1) =3D=3D const0_rtx); > + rtx set =3D XVECEXP (op, 0, 0); > + return (GET_CODE (set) =3D=3D SET > + && MEM_P (SET_DEST (set)) > + && GET_MODE (SET_DEST (set)) =3D=3D BLKmode > + && GET_CODE (SET_SRC (set)) =3D=3D UNSPEC > + && XINT (SET_SRC (set), 1) =3D=3D UNSPEC_TIE > + && XVECEXP (SET_SRC (set), 0, 0) =3D=3D const0_rtx); > }) > > ;; Match a small code model toc reference (or medium and large > diff --git a/gcc/config/rs6000/rs6000-logue.cc b/gcc/config/rs6000/rs6000= -logue.cc > index bc6b153b59f..b99f43a8282 100644 > --- a/gcc/config/rs6000/rs6000-logue.cc > +++ b/gcc/config/rs6000/rs6000-logue.cc > @@ -1463,7 +1463,9 @@ rs6000_emit_stack_tie (rtx fp, bool hard_frame_need= ed) > while (--i >=3D 0) > { > rtx mem =3D gen_frame_mem (BLKmode, regs[i]); > - RTVEC_ELT (p, i) =3D gen_rtx_SET (mem, const0_rtx); > + RTVEC_ELT (p, i) > + =3D gen_rtx_SET (mem, gen_rtx_UNSPEC (BLKmode, gen_rtvec (1, cons= t0_rtx), > + UNSPEC_TIE)); > } > > emit_insn (gen_stack_tie (gen_rtx_PARALLEL (VOIDmode, p))); > diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc > index d197c3f3289..0c81ebea711 100644 > --- a/gcc/config/rs6000/rs6000.cc > +++ b/gcc/config/rs6000/rs6000.cc > @@ -1760,6 +1760,10 @@ static const struct attribute_spec rs6000_attribut= e_table[] =3D > > #undef TARGET_UPDATE_IPA_FN_TARGET_INFO > #define TARGET_UPDATE_IPA_FN_TARGET_INFO rs6000_update_ipa_fn_target_inf= o > + > +#undef TARGET_CONST_ANCHOR > +#define TARGET_CONST_ANCHOR 0x8000 > + > > > /* Processor table. */ > diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md > index b0db8ae508d..fdcf8347812 100644 > --- a/gcc/config/rs6000/rs6000.md > +++ b/gcc/config/rs6000/rs6000.md > @@ -158,6 +158,7 @@ (define_c_enum "unspec" > UNSPEC_HASHCHK > UNSPEC_XXSPLTIDP_CONST > UNSPEC_XXSPLTIW_CONST > + UNSPEC_TIE > ]) > > ;; > @@ -10828,7 +10829,9 @@ (define_expand "restore_stack_block" > operands[4] =3D gen_frame_mem (Pmode, operands[1]); > p =3D rtvec_alloc (1); > RTVEC_ELT (p, 0) =3D gen_rtx_SET (gen_frame_mem (BLKmode, operands[0])= , > - const0_rtx); > + gen_rtx_UNSPEC (BLKmode, > + gen_rtvec (1, const0_rt= x), > + UNSPEC_TIE)); > operands[5] =3D gen_rtx_PARALLEL (VOIDmode, p); > }) > > @@ -10866,7 +10869,9 @@ (define_expand "restore_stack_nonlocal" > operands[5] =3D gen_frame_mem (Pmode, operands[3]); > p =3D rtvec_alloc (1); > RTVEC_ELT (p, 0) =3D gen_rtx_SET (gen_frame_mem (BLKmode, operands[0])= , > - const0_rtx); > + gen_rtx_UNSPEC (BLKmode, > + gen_rtvec (1, const0_rt= x), > + UNSPEC_TIE)); > operands[6] =3D gen_rtx_PARALLEL (VOIDmode, p); > }) > > @@ -13898,7 +13903,8 @@ (define_insn "*save_fpregs__r1" > ; not be moved over loads from or stores to stack memory. > (define_insn "stack_tie" > [(match_parallel 0 "tie_operand" > - [(set (mem:BLK (reg 1)) (const_int 0))])] > + [(set (mem:BLK (reg 1)) > + (unspec:BLK [(const_int 0)] UNSPEC_TIE))])] > "" > "" > [(set_attr "length" "0")]) > @@ -13910,7 +13916,7 @@ (define_insn "stack_restore_tie" > [(set (match_operand:SI 0 "gpc_reg_operand" "=3Dr,r") > (plus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r") > (match_operand:SI 2 "reg_or_cint_operand" "O,rI"))) > - (set (mem:BLK (scratch)) (const_int 0))] > + (set (mem:BLK (scratch)) (unspec:BLK [(const_int 0)] UNSPEC_TIE))] > "TARGET_32BIT" > "@ > mr %0,%1 > -- > 2.39.3 >