From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7795 invoked by alias); 4 Jun 2011 15:20:14 -0000 Received: (qmail 7786 invoked by uid 22791); 4 Jun 2011 15:20:12 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST X-Spam-Check-By: sourceware.org Received: from mail-qy0-f182.google.com (HELO mail-qy0-f182.google.com) (209.85.216.182) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 04 Jun 2011 15:19:58 +0000 Received: by qyk27 with SMTP id 27so1412221qyk.20 for ; Sat, 04 Jun 2011 08:19:58 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.131.32 with SMTP id v32mr2305641qcs.35.1307200797516; Sat, 04 Jun 2011 08:19:57 -0700 (PDT) Received: by 10.229.39.78 with HTTP; Sat, 4 Jun 2011 08:19:57 -0700 (PDT) In-Reply-To: <20110420160959.GR17079@tyan-ft48-01.lab.bos.redhat.com> References: <20110420160959.GR17079@tyan-ft48-01.lab.bos.redhat.com> Date: Sat, 04 Jun 2011 15:20:00 -0000 Message-ID: Subject: Re: [PATCH] Optimize (x * 8) | 5 and (x << 3) ^ 3 to use lea (PR target/48688) From: "H.J. Lu" To: Jakub Jelinek Cc: Uros Bizjak , gcc-patches@gcc.gnu.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes 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 X-SW-Source: 2011-06/txt/msg00310.txt.bz2 On Wed, Apr 20, 2011 at 9:09 AM, Jakub Jelinek wrote: > Hi! > > This splitter allows us to optimize (x {* {2,4,8},<< {1,2,3}}) {|,^} y > for constant integer y <=3D {1ULL,3ULL,7ULL} using lea{l,q} (| or ^ in > that case, when the low bits are known to be all 0, is like plus). > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? > > 2011-04-20 =A0Jakub Jelinek =A0 > > =A0 =A0 =A0 =A0PR target/48688 > =A0 =A0 =A0 =A0* config/i386/i386.md (*lea_general_4): New define_insn_an= d_split. > > =A0 =A0 =A0 =A0* gcc.target/i386/pr48688.c: New test. > > --- gcc/config/i386/i386.md.jj =A02011-04-19 14:08:55.000000000 +0200 > +++ gcc/config/i386/i386.md =A0 =A0 2011-04-20 14:34:50.000000000 +0200 > @@ -6646,6 +6646,40 @@ (define_insn_and_split "*lea_general_3_z > =A0} > =A0 [(set_attr "type" "lea") > =A0 =A0(set_attr "mode" "SI")]) > + > +(define_insn_and_split "*lea_general_4" > + =A0[(set (match_operand:SWI 0 "register_operand" "=3Dr") > + =A0 =A0 =A0 (any_or:SWI (ashift:SWI (match_operand:SWI 1 "index_registe= r_operand" "l") > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (match_oper= and:SWI 2 "const_int_operand" "n")) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (match_operand 3 "const_int_operand= " "n")))] > + =A0"(mode =3D=3D DImode > + =A0 =A0|| mode =3D=3D SImode > + =A0 =A0|| !TARGET_PARTIAL_REG_STALL > + =A0 =A0|| optimize_function_for_size_p (cfun)) > + =A0 && ((unsigned HOST_WIDE_INT) INTVAL (operands[2])) - 1 < 3 > + =A0 && ((unsigned HOST_WIDE_INT) INTVAL (operands[3]) > + =A0 =A0 =A0 <=3D ((unsigned HOST_WIDE_INT) 1 << INTVAL (operands[2])))" > + =A0"#" > + =A0"&& reload_completed" > + =A0[(const_int 0)] > +{ > + =A0rtx pat; > + =A0if (mode !=3D DImode) > + =A0 =A0operands[0] =3D gen_lowpart (SImode, operands[0]); > + =A0operands[1] =3D gen_lowpart (Pmode, operands[1]); > + =A0operands[2] =3D GEN_INT (1 << INTVAL (operands[2])); > + =A0pat =3D plus_constant (gen_rtx_MULT (Pmode, operands[1], operands[2]= ), > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0INTVAL (operands[3])); > + =A0if (Pmode !=3D SImode && mode !=3D DImode) > + =A0 =A0pat =3D gen_rtx_SUBREG (SImode, pat, 0); > + =A0emit_insn (gen_rtx_SET (VOIDmode, operands[0], pat)); > + =A0DONE; > +} > + =A0[(set_attr "type" "lea") > + =A0 (set (attr "mode") > + =A0 =A0 =A0(if_then_else (eq (symbol_ref "mode =3D=3D DImode") (c= onst_int 0)) > + =A0 =A0 =A0 (const_string "SI") > + =A0 =A0 =A0 (const_string "DI")))]) > > =A0;; Subtract instructions I don't think this pattern is correct. See: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D49281 H.J.