From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11295 invoked by alias); 10 Apr 2015 09:14:06 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 11281 invoked by uid 89); 10 Apr 2015 09:14:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.2 X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (146.101.78.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 10 Apr 2015 09:14:04 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by uk-mta-3.uk.mimecast.lan; Fri, 10 Apr 2015 10:14:00 +0100 Received: from [10.2.206.45] ([10.1.2.79]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 10 Apr 2015 10:14:00 +0100 Message-ID: <55279458.6000601@arm.com> Date: Fri, 10 Apr 2015 09:14:00 -0000 From: Alex Velenko User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: Jeff Law , Steven Bosscher CC: GCC Patches , Marcus Shawcroft Subject: Re: [PATCH] [RTL] Relax CSE check to set REG_EQUAL notes. References: <1425467354-6018-1-git-send-email-alex.velenko@arm.com> <54FDDB1C.2000006@redhat.com> In-Reply-To: <54FDDB1C.2000006@redhat.com> X-MC-Unique: gye74ACaT4KTuQT9udxdQw-1 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2015-04/txt/msg00441.txt.bz2 On 09/03/15 17:40, Jeff Law wrote: > On 03/09/15 03:53, Steven Bosscher wrote: >> On Wed, Mar 4, 2015 at 12:09 PM, Alex Velenko wrote: >>> For example, in arm testcase pr43920-2.c, CSE previously decided not to= put >>> an "obvious" note on insn 9, as set value was the same as note value. >>> At the same time, other insns set up as -1 were set up through a regist= er >>> and did get a note: >> >> ...which is the point of the REG_EQUAL notes. In insn 8 there is a >> REG_EQUAL note to show that the value of r111 is known. In insn 9 the >> known value is, well, known from SET_SRC so there is no need for a >> REG_EQUAL note. Adding REG_EQUAL notes in such cases is just wasteful. > RIght. I'd rather look into why later passes aren't discovering > whatever equivalences are important rather than adding the redundant note= s. > > Regardless, I think this is a gcc-6 issue, so I'm not likely to look at > it in the immediate future. > > jeff > > Hi Jeff, I reworked the patch to satisfy your preference. This patch enables cfgcleanup.c to use const int rtx as REG_EQUAL notes. For example, this benefits Jump2 to find extra optimisation opportunities. This patch fixes gcc.target/arm/pr43920-2.c for arm-none-eabi. Bootstraped on x86, run full regression run on arm-none-eabi and aarch64-none-elf. Is this patch ok? gcc/ 2015-03-17 Alex Velenko * cfgcleanup.c (can_replace_by): Use const int rtx of single set as REG_EQUAL note. --- gcc/cfgcleanup.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c index cee152e..b28a1d3 100644 --- a/gcc/cfgcleanup.c +++ b/gcc/cfgcleanup.c @@ -1046,7 +1046,7 @@ equal_different_set_p (rtx p1, rtx s1, rtx p2, rtx s2) static enum replace_direction can_replace_by (rtx_insn *i1, rtx_insn *i2) { - rtx s1, s2, d1, d2, src1, src2, note1, note2; + rtx s1, s2, d1, d2, src1, src2, note1, note2, cmp_rtx1, cmp_rtx2; bool c1, c2; /* Check for 2 sets. */ @@ -1062,12 +1062,29 @@ can_replace_by (rtx_insn *i1, rtx_insn *i2) ? rtx_renumbered_equal_p (d1, d2) : rtx_equal_p (d1, d2))) return dir_none; + src1 =3D SET_SRC (s1); + src2 =3D SET_SRC (s2); + /* Find identical req_equiv or reg_equal note, which implies that=20 the 2 sets set dest to the same value. */ note1 =3D find_reg_equal_equiv_note (i1); note2 =3D find_reg_equal_equiv_note (i2); - if (!note1 || !note2 || !rtx_equal_p (XEXP (note1, 0), XEXP (note2, 0)) - || !CONST_INT_P (XEXP (note1, 0))) + + cmp_rtx1 =3D NULL_RTX; + cmp_rtx2 =3D NULL_RTX; + + if (note1) + cmp_rtx1 =3D XEXP (note1, 0); + else if (CONST_INT_P (src1)) + cmp_rtx1 =3D src1; + + if (note2) + cmp_rtx2 =3D XEXP (note2, 0); + else if (CONST_INT_P (src2)) + cmp_rtx2 =3D src2; + + if (!cmp_rtx1 || !cmp_rtx2 || !rtx_equal_p (cmp_rtx1, cmp_rtx2) + || !CONST_INT_P (cmp_rtx1)) return dir_none; if (!equal_different_set_p (PATTERN (i1), s1, PATTERN (i2), s2)) @@ -1079,8 +1096,6 @@ can_replace_by (rtx_insn *i1, rtx_insn *i2) (set (dest) (reg)) because we don't know if the reg is live and has the same value=20 at the location of replacement. */ - src1 =3D SET_SRC (s1); - src2 =3D SET_SRC (s2); c1 =3D CONST_INT_P (src1); c2 =3D CONST_INT_P (src2); if (c1 && c2) -- 1.8.1.2