From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 93664 invoked by alias); 11 Sep 2015 16:16:00 -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 93649 invoked by uid 89); 11 Sep 2015 16:16:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 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) (207.82.80.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 11 Sep 2015 16:15:54 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-2--JrVAlROSWKuIdnnZnsiSA-1; Fri, 11 Sep 2015 17:15:49 +0100 Received: from [10.2.207.50] ([10.1.2.79]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 11 Sep 2015 17:15:48 +0100 Message-ID: <55F2FE34.9060101@arm.com> Date: Fri, 11 Sep 2015 16:29:00 -0000 From: Kyrill Tkachov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: James Greenhalgh CC: GCC Patches , Marcus Shawcroft , Richard Earnshaw Subject: Re: [PATCH][AArch64] Use preferred aliases for CSNEG, CSINC, CSINV References: <55E5790A.2090205@arm.com> <20150911153146.GA5206@arm.com> In-Reply-To: <20150911153146.GA5206@arm.com> X-MC-Unique: -JrVAlROSWKuIdnnZnsiSA-1 Content-Type: text/plain; charset=WINDOWS-1252; format=flowed Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2015-09/txt/msg00821.txt.bz2 On 11/09/15 16:31, James Greenhalgh wrote: > On Tue, Sep 01, 2015 at 11:08:10AM +0100, Kyrill Tkachov wrote: >> Hi all, >> >> The ARMv8-A reference manual says: >> "CNEG , , >> is equivalent to >> CSNEG , , , invert() >> and is the preferred disassembly when Rn =3D=3D Rm && cond !=3D '111x'." >> >> That is, when the two input registers are the same we can use the shorte= r CNEG mnemonic >> with the inverse condition instead of the longer CSNEG instruction. Simi= larly for the >> CSINV and CSINC instructions, they have shorter CINV and CINC forms. >> This patch adjusts the output templates to emit the preferred shorter se= quences when possible. >> >> The new mnemonics are just aliases, they map down to the same instructio= n in the end, so there >> are no performance or behaviour implications. But it does make the assem= bly a bit more readable >> IMO, since: >> "cneg w27, w9, le" >> can be simply read as "if the condition is less or equal negate w9" inst= ead of the previous: >> "csneg w27, w9, w9, gt" where you have to remember which of the input= registers is negated. >> >> >> Bootstrapped and tested on aarch64-linux-gnu. >> Ok for trunk? >> >> diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.= md >> index 77bc7cd..2e4b26c 100644 >> --- a/gcc/config/aarch64/aarch64.md >> +++ b/gcc/config/aarch64/aarch64.md >> @@ -3090,7 +3090,12 @@ (define_insn "csinc3_insn" >> (const_int 1)) >> (match_operand:GPI 3 "aarch64_reg_or_zero" "rZ")))] >> "" >> - "csinc\\t%0, %3, %2, %M1" >> + { >> + if (rtx_equal_p (operands[2], operands[3])) >> + return "cinc\\t%0, %2, %m1"; >> + else >> + return "csinc\\t%0, %3, %2, %M1"; >> + } >> [(set_attr "type" "csel")] >> ) > I guess you do it this way rather than just adding a new alternative in > the pattern to avoid any chance of constraining the register allocator, b= ut > would this not be more natural to read as an {r, r, r, 2} alternative, or > similar? I had not considered this approach and I'm a bit sceptical on how feasible = it is. If we put the {r,r,r,2} as a second alternative then it will be a purely mo= re restrictive version of the first alternative and so will never match. If, however, we put it as the first alternative we'll be expressing some pr= eference for allocating the same register for operands 2 and 3, which is not something w= e want to do. > > If you've given that some thought and decided it doesn't work for you, > then this is OK for trunk. Given the above I'll commit this version next week if there are no objections. Thanks, Kyrill > > Thanks, > James >