From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 34394 invoked by alias); 4 Mar 2015 11:09:36 -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 34370 invoked by uid 89); 4 Mar 2015 11:09:35 -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: service87.mimecast.com Received: from service87.mimecast.com (HELO service87.mimecast.com) (91.220.42.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 04 Mar 2015 11:09:34 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by service87.mimecast.com; Wed, 04 Mar 2015 11:09:31 +0000 Received: from e104458-lin.cambridge.arm.com ([10.1.255.212]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 4 Mar 2015 11:09:30 +0000 From: Alex Velenko To: gcc-patches@gcc.gnu.org Cc: Marcus.Shawcroft@arm.com Subject: [PATCH] [RTL] Relax CSE check to set REG_EQUAL notes. Date: Wed, 04 Mar 2015 11:09:00 -0000 Message-Id: <1425467354-6018-1-git-send-email-alex.velenko@arm.com> X-MC-Unique: 115030411093106601 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2015-03/txt/msg00200.txt.bz2 Hi, This patch permits CSE to add REG_EQUAL notes when single setting a constant to a register even if REG_EQUAL constant rtx is the same as the set source = rtx. This enables optimizations in later passes looking for REG_EQUAL notes, like jump2 pass. 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 register and did get a note: (insn 9 53 34 8 (set (reg:SI 110 [ D.4934 ]) (const_int -1 [0xffffffffffffffff])) /work/src/gcc/gcc/testsuite/gc= c.target/arm/pr43920-2.c:21 613 {*thumb2_movsi_vfp} (nil)) (insn 8 45 50 6 (set (reg:SI 110 [ D.4934 ]) (reg/v:SI 111 [ startD.4917 ])) /work/src/gcc/gcc/testsuite/gcc.tar= get/arm/pr43920-2.c:21 613 {*thumb2_movsi_vfp} (expr_list:REG_EQUAL (const_int -1 [0xffffffffffffffff]) (nil))) (insn 6 49 54 7 (set (reg:SI 110 [ D.4934 ]) (reg/v:SI 112 [ endD.4918 ])) /work/src/gcc/gcc/testsuite/gcc.targe= t/arm/pr43920-2.c:21 613 {*thumb2_movsi_vfp} (expr_list:REG_EQUAL (const_int -1 [0xffffffffffffffff]) (nil))) Jump2 pass, optimizing common code, was looking at notes to reason about register values and failing to recognize those insns to be equal. Making CSE to set up REG_EQUAL notes even in "obvious" cases fixes pr43920-2.c for arm-none-eabi and other targets. I prefer adding notes in CSE instead of adding additional checks in Jump2 and, if any, other passes, as I think it is more uniform solution and allows single point fix. Downside is having more notes. Done full regression run on arm-none-eabi and bootstrapped on x86. Is patch ok? gcc/ 2015-03-04 Alex Velenko * cse.c (cse_insn): Check to set REG_EQUAL note relaxed. --- gcc/cse.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/gcc/cse.c b/gcc/cse.c index 2a33827..abaf867 100644 --- a/gcc/cse.c +++ b/gcc/cse.c @@ -5383,10 +5383,9 @@ cse_insn (rtx_insn *insn) } =20 /* If this is a single SET, we are setting a register, and we have an - equivalent constant, we want to add a REG_EQUAL note if the constant - is different from the source. We don't want to do it for a constant - pseudo since verifying that this pseudo hasn't been eliminated is a - pain; moreover such a note won't help anything. + equivalent constant, we want to add a REG_EQUAL note. We don't want + to do it for a constant pseudo since verifying that this pseudo hasn't + been eliminated is a pain; moreover such a note won't help anything. =20 Avoid a REG_EQUAL note for (CONST (MINUS (LABEL_REF) (LABEL_REF))) which can be created for a reference to a compile time computable @@ -5400,8 +5399,7 @@ cse_insn (rtx_insn *insn) && !(GET_CODE (src_const) =3D=3D CONST && GET_CODE (XEXP (src_const, 0)) =3D=3D MINUS && GET_CODE (XEXP (XEXP (src_const, 0), 0)) =3D=3D LABEL_REF - && GET_CODE (XEXP (XEXP (src_const, 0), 1)) =3D=3D LABEL_REF) - && !rtx_equal_p (src, src_const)) + && GET_CODE (XEXP (XEXP (src_const, 0), 1)) =3D=3D LABEL_REF)) { /* Make sure that the rtx is not shared. */ src_const =3D copy_rtx (src_const); --=20 1.8.1.2