From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from xry111.site (xry111.site [IPv6:2001:470:683e::1]) by sourceware.org (Postfix) with ESMTPS id 072523858017 for ; Mon, 28 Aug 2023 09:21:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 072523858017 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=xry111.site Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=xry111.site DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1693214463; bh=vtNXREmQx6qfV/LVA3ZgYcqmsm0EwA0jmTmMMrMc30Q=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=NWMCXdvdNQaq5DYvgQxfnkxhWOT23Ub+dsuGWZQSget8kXQAJifHaP5YMsCtXM0hx AyCt0TCfSUZG0pXYbgRXVK/nO1fm4VFbjXHtEKrOL0KiY5Ee0Mk//E6jvwHg7jN0w5 lRdUZSgly5NsBaoG4vuyQ351lKyW3yD798/cqseA= Received: from localhost.localdomain (xry111.site [IPv6:2001:470:683e::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id 93A7E659AC; Mon, 28 Aug 2023 05:21:02 -0400 (EDT) Message-ID: <15f4707d1be50cef5e41a0015a38829b1a1fe202.camel@xry111.site> Subject: Re: [PATCH v2] LoongArch: Enable '-free' starting at -O2. From: Xi Ruoyao To: Lulu Cheng , gcc-patches@gcc.gnu.org Cc: i@xen0n.name, xuchenghua@loongson.cn Date: Mon, 28 Aug 2023 17:21:00 +0800 In-Reply-To: <20230828034652.22768-1-chenglulu@loongson.cn> References: <20230828034652.22768-1-chenglulu@loongson.cn> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 MIME-Version: 1.0 X-Spam-Status: No, score=-6.3 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,LIKELY_SPAM_FROM,SPF_HELO_PASS,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 List-Id: On Mon, 2023-08-28 at 11:46 +0800, Lulu Cheng wrote: > v1 -> v2: > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A01. Modify Changelog infor= mation format. >=20 > gcc/ChangeLog: >=20 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0* common/config/loongarch= /loongarch-common.cc: > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0Enable '-free' on O2 and = above. > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0* doc/invoke.texi: Modify= the description information > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0of the '-free' compilatio= n option and add the LoongArch > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0description. >=20 > gcc/testsuite/ChangeLog: >=20 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0* gcc.target/loongarch/si= gn-extend.c: New test. LGTM. > --- > =C2=A0.../config/loongarch/loongarch-common.cc=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 |=C2=A0 1 + > =C2=A0gcc/doc/invoke.texi=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 4 +-- > =C2=A0.../gcc.target/loongarch/sign-extend.c=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 | 25 +++++++++++++++++++ > =C2=A03 files changed, 28 insertions(+), 2 deletions(-) > =C2=A0create mode 100644 gcc/testsuite/gcc.target/loongarch/sign-extend.c >=20 > diff --git a/gcc/common/config/loongarch/loongarch-common.cc b/gcc/common= /config/loongarch/loongarch-common.cc > index fce32fa3f8d..c5ed37d27a6 100644 > --- a/gcc/common/config/loongarch/loongarch-common.cc > +++ b/gcc/common/config/loongarch/loongarch-common.cc > @@ -35,6 +35,7 @@ static const struct default_options loongarch_option_op= timization_table[] =3D > =C2=A0{ > =C2=A0=C2=A0 { OPT_LEVELS_ALL, OPT_fasynchronous_unwind_tables, NULL, 1 }= , > =C2=A0=C2=A0 { OPT_LEVELS_1_PLUS, OPT_fsection_anchors, NULL, 1 }, > +=C2=A0 { OPT_LEVELS_2_PLUS, OPT_free, NULL, 1 }, > =C2=A0=C2=A0 { OPT_LEVELS_NONE, 0, NULL, 0 } > =C2=A0}; > =C2=A0 > diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi > index a32dabf0405..16aa92b5e86 100644 > --- a/gcc/doc/invoke.texi > +++ b/gcc/doc/invoke.texi > @@ -12639,8 +12639,8 @@ Attempt to remove redundant extension instruction= s.=C2=A0 This is especially > =C2=A0helpful for the x86-64 architecture, which implicitly zero-extends = in 64-bit > =C2=A0registers after writing to their lower 32-bit half. > =C2=A0 > -Enabled for Alpha, AArch64, PowerPC, RISC-V, SPARC, h83000 and x86 at le= vels > -@option{-O2}, @option{-O3}, @option{-Os}. > +Enabled for Alpha, AArch64, LoongArch, PowerPC, RISC-V, SPARC, h83000 an= d x86 at > +levels @option{-O2}, @option{-O3}, @option{-Os}. > =C2=A0 > =C2=A0@opindex fno-lifetime-dse > =C2=A0@opindex flifetime-dse > diff --git a/gcc/testsuite/gcc.target/loongarch/sign-extend.c b/gcc/tests= uite/gcc.target/loongarch/sign-extend.c > new file mode 100644 > index 00000000000..3f339d06bbd > --- /dev/null > +++ b/gcc/testsuite/gcc.target/loongarch/sign-extend.c > @@ -0,0 +1,25 @@ > +/* { dg-do compile } */ > +/* { dg-options "-mabi=3Dlp64d -O2" } */ > +/* { dg-final { scan-assembler-times "slli.w" 1 } } */ > + > +extern int PL_savestack_ix; > +extern int PL_regsize; > +extern int PL_savestack_max; > +void Perl_savestack_grow_cnt (int need); > +extern void Perl_croak (char *); > + > +int > +S_regcppush(int parenfloor) > +{ > +=C2=A0 int retval =3D PL_savestack_ix; > +=C2=A0 int paren_elems_to_push =3D (PL_regsize - parenfloor) * 4; > +=C2=A0 int p; > + > +=C2=A0 if (paren_elems_to_push < 0) > +=C2=A0=C2=A0=C2=A0 Perl_croak ("panic: paren_elems_to_push < 0"); > + > +=C2=A0 if (PL_savestack_ix + (paren_elems_to_push + 6) > PL_savestack_ma= x) > +=C2=A0=C2=A0=C2=A0 Perl_savestack_grow_cnt (paren_elems_to_push + 6); > + > +=C2=A0 return retval; > +} --=20 Xi Ruoyao School of Aerospace Science and Technology, Xidian University