From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18283 invoked by alias); 13 Aug 2014 15:30: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 18175 invoked by uid 89); 13 Aug 2014 15:30:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 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, 13 Aug 2014 15:30:04 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Wed, 13 Aug 2014 16:30:02 +0100 Received: from [10.1.208.24] ([10.1.255.212]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 13 Aug 2014 16:30:00 +0100 Message-ID: <53EB8477.80208@arm.com> Date: Wed, 13 Aug 2014 15:30:00 -0000 From: Kyrill Tkachov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: Richard Henderson , Richard Earnshaw CC: gcc-patches Subject: Re: [PATCH, AArch64] Use MOVN to generate 64-bit negative immediates where sensible References: <000001cf6ae4$059c2280$10d46780$@bolton@arm.com> <537605FF.8070700@arm.com> <53E363C2.4000405@arm.com> <53E37532.60101@arm.com> <53E3779C.1020709@arm.com> <53E3D467.2020509@redhat.com> In-Reply-To: <53E3D467.2020509@redhat.com> X-MC-Unique: 114081316300202701 Content-Type: multipart/mixed; boundary="------------070302010408040906060701" X-IsSubscribed: yes X-SW-Source: 2014-08/txt/msg01329.txt.bz2 This is a multi-part message in MIME format. --------------070302010408040906060701 Content-Type: text/plain; charset=WINDOWS-1252; format=flowed Content-Transfer-Encoding: quoted-printable Content-length: 1819 On 07/08/14 20:32, Richard Henderson wrote: > On 08/07/2014 02:57 AM, Kyrill Tkachov wrote: >> + if (one_match > zero_match) >> + { >> + /* Set either first three quarters or all but the third. */ >> + mask =3D 0xffffll << (16 - first_not_ffff_match); >> + emit_insn (gen_rtx_SET (VOIDmode, dest, >> + GEN_INT (val | mask | 0xffffffff00000000ull))); >> + >> + /* Now insert other two quarters. */ >> + for (i =3D first_not_ffff_match + 16, mask <<=3D (first_not_ffff_= match << 1); >> + i < 64; i +=3D 16, mask <<=3D 16) >> { >> if ((val & mask) !=3D mask) >> + emit_insn (gen_insv_immdi (dest, GEN_INT (i), >> + GEN_INT ((val >> i) & 0xffff))); >> } >> + return; >> } >>=20=20=20 >> if (zero_match =3D=3D 2) > You should not place this three instruction sequence before the two instr= uction > sequences that follow. I.e. place this just before simple_sequence. Hi Richard, Is the attached patch ok? It just moves the section as you suggested. I=20 did a build of the Linux kernel with and without this patch to make sure=20 no code-gen was accidentally affected. > > I do wonder if we should be memo-izing these computations so that we only= have > to do the complex search for a sequence only once for each constant... We'd need to store a mapping from constant to RTXes and everytime we=20 have a "cache hit" we'd have to tweak them to make sure the registers=20 involved are correct. I had a quick play with this but ended up with LRA=20 ICEs :( Might look at it later on, but it's not high on my priorities right now. Thanks, Kyrill 2014-08-13 Kyrylo Tkachov * config/aarch64/aarch64.c (aarch64_expand_mov_immediate): Move one_match > zero_match case to just before simple_sequence.= --------------070302010408040906060701 Content-Type: text/x-patch; name=aarch64-movn-mov.patch Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="aarch64-movn-mov.patch" Content-length: 1680 diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index 20debb9..a4e7158 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -1136,24 +1136,6 @@ aarch64_expand_mov_immediate (rtx dest, rtx imm) return; } =20 - if (one_match > zero_match) - { - /* Set either first three quarters or all but the third. */ - mask =3D 0xffffll << (16 - first_not_ffff_match); - emit_insn (gen_rtx_SET (VOIDmode, dest, - GEN_INT (val | mask | 0xffffffff00000000ull))); - - /* Now insert other two quarters. */ - for (i =3D first_not_ffff_match + 16, mask <<=3D (first_not_ffff_mat= ch << 1); - i < 64; i +=3D 16, mask <<=3D 16) - { - if ((val & mask) !=3D mask) - emit_insn (gen_insv_immdi (dest, GEN_INT (i), - GEN_INT ((val >> i) & 0xffff))); - } - return; - } - if (zero_match =3D=3D 2) goto simple_sequence; =20 @@ -1270,6 +1252,24 @@ aarch64_expand_mov_immediate (rtx dest, rtx imm) } } =20 + if (one_match > zero_match) + { + /* Set either first three quarters or all but the third. */ + mask =3D 0xffffll << (16 - first_not_ffff_match); + emit_insn (gen_rtx_SET (VOIDmode, dest, + GEN_INT (val | mask | 0xffffffff00000000ull))); + + /* Now insert other two quarters. */ + for (i =3D first_not_ffff_match + 16, mask <<=3D (first_not_ffff_mat= ch << 1); + i < 64; i +=3D 16, mask <<=3D 16) + { + if ((val & mask) !=3D mask) + emit_insn (gen_insv_immdi (dest, GEN_INT (i), + GEN_INT ((val >> i) & 0xffff))); + } + return; + } + simple_sequence: first =3D true; mask =3D 0xffff;= --------------070302010408040906060701--