From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25395 invoked by alias); 13 Oct 2015 08:21:18 -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 25373 invoked by uid 89); 13 Oct 2015 08:21:16 -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; Tue, 13 Oct 2015 08:21:11 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-34-JOk3DboCQAuyV_g9LaxJrQ-1; Tue, 13 Oct 2015 09:21:07 +0100 Received: from [10.2.207.50] ([10.1.2.79]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 13 Oct 2015 09:21:06 +0100 Message-ID: <561CBEF2.3000806@arm.com> Date: Tue, 13 Oct 2015 08:21: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: GCC Patches CC: Marcus Shawcroft , Richard Earnshaw , James Greenhalgh Subject: Re: [PATCH][AArch64] Improve comparison with complex immediates followed by branch/cset References: <56162F33.6060103@arm.com> In-Reply-To: <56162F33.6060103@arm.com> X-MC-Unique: JOk3DboCQAuyV_g9LaxJrQ-1 Content-Type: text/plain; charset=WINDOWS-1252; format=flowed Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2015-10/txt/msg01195.txt.bz2 On 08/10/15 09:54, Kyrill Tkachov wrote: > Hi all, > > This patch slightly improves sequences where we want to compare against a= complex immediate and branch against the result > or perform a cset on it. > This means transforming sequences of mov+movk+cmp+branch into sub+subs+br= anch. > Similar for cset. Unfortunately I can't just do this by simply matching a= (compare (reg) (const_int)) rtx because > this transformation is only valid for equal/not equal comparisons, not gr= eater than/less than ones but the compare instruction > pattern only has the general CC mode. We need to also match the use of th= e condition code. > > I've done this by creating a splitter for the conditional jump where the = condition is the comparison between the register > and the complex immediate and splitting it into the sub+subs+condjump seq= uence. Similar for the cstore pattern. > Thankfully we don't split immediate moves until later in the optimization= pipeline so combine can still try the right patterns. > With this patch for the example code: > void g(void); > void f8(int x) > { > if (x !=3D 0x123456) g(); > } > > I get: > f8: > sub w0, w0, #1191936 > subs w0, w0, #1110 > beq .L1 > b g > .p2align 3 > .L1: > ret > > instead of the previous: > f8: > mov w1, 13398 > movk w1, 0x12, lsl 16 > cmp w0, w1 > beq .L1 > b g > .p2align 3 > .L1: > ret > > > The condjump case triggered 130 times across all of SPEC2006 which is, ad= mittedly, not much > whereas the cstore case didn't trigger at all. However, the included test= case in the patch > demonstrates the kind of code that it would trigger on. > > Bootstrapped and tested on aarch64. > > Ok for trunk? There's a few changes I'd like to make to this patch and I'll post an updat= ed version when it's ready. So no need to review this version, besides getting the general idea of the = transformation... Sorry for the noise, Kyrill > Thanks, > Kyrill > > > 2015-10-08 Kyrylo Tkachov > > * config/aarch64/aarch64.md (*condjump): Rename to... > (condjump): ... This. > (*compare_condjump): New define_insn_and_split. > (*compare_cstore_insn): Likewise. > (*cstore_insn): Rename to... > (cstore_insn): ... This. > * config/aarch64/iterators.md (CMP): Handle ne code. > * config/aarch64/predicates.md (aarch64_imm24): New predicate. > > 2015-10-08 Kyrylo Tkachov > > * gcc.target/aarch64/cmpimm_branch_1.c: New test. > * gcc.target/aarch64/cmpimm_cset_1.c: Likewise.