public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Uros Bizjak <ubizjak@gmail.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Optimize (x * 8) | 5 and (x << 3) ^ 3 to use lea (PR target/48688)
Date: Sat, 04 Jun 2011 15:20:00 -0000	[thread overview]
Message-ID: <BANLkTinhGA=AzSkLuyrBXBDpmU48SSnY2w@mail.gmail.com> (raw)
In-Reply-To: <20110420160959.GR17079@tyan-ft48-01.lab.bos.redhat.com>

On Wed, Apr 20, 2011 at 9:09 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> This splitter allows us to optimize (x {* {2,4,8},<< {1,2,3}}) {|,^} y
> for constant integer y <= {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  Jakub Jelinek  <jakub@redhat.com>
>
>        PR target/48688
>        * config/i386/i386.md (*lea_general_4): New define_insn_and_split.
>
>        * gcc.target/i386/pr48688.c: New test.
>
> --- gcc/config/i386/i386.md.jj  2011-04-19 14:08:55.000000000 +0200
> +++ gcc/config/i386/i386.md     2011-04-20 14:34:50.000000000 +0200
> @@ -6646,6 +6646,40 @@ (define_insn_and_split "*lea_general_3_z
>  }
>   [(set_attr "type" "lea")
>    (set_attr "mode" "SI")])
> +
> +(define_insn_and_split "*lea_general_4"
> +  [(set (match_operand:SWI 0 "register_operand" "=r")
> +       (any_or:SWI (ashift:SWI (match_operand:SWI 1 "index_register_operand" "l")
> +                               (match_operand:SWI 2 "const_int_operand" "n"))
> +                   (match_operand 3 "const_int_operand" "n")))]
> +  "(<MODE>mode == DImode
> +    || <MODE>mode == SImode
> +    || !TARGET_PARTIAL_REG_STALL
> +    || optimize_function_for_size_p (cfun))
> +   && ((unsigned HOST_WIDE_INT) INTVAL (operands[2])) - 1 < 3
> +   && ((unsigned HOST_WIDE_INT) INTVAL (operands[3])
> +       <= ((unsigned HOST_WIDE_INT) 1 << INTVAL (operands[2])))"
> +  "#"
> +  "&& reload_completed"
> +  [(const_int 0)]
> +{
> +  rtx pat;
> +  if (<MODE>mode != DImode)
> +    operands[0] = gen_lowpart (SImode, operands[0]);
> +  operands[1] = gen_lowpart (Pmode, operands[1]);
> +  operands[2] = GEN_INT (1 << INTVAL (operands[2]));
> +  pat = plus_constant (gen_rtx_MULT (Pmode, operands[1], operands[2]),
> +                      INTVAL (operands[3]));
> +  if (Pmode != SImode && <MODE>mode != DImode)
> +    pat = gen_rtx_SUBREG (SImode, pat, 0);
> +  emit_insn (gen_rtx_SET (VOIDmode, operands[0], pat));
> +  DONE;
> +}
> +  [(set_attr "type" "lea")
> +   (set (attr "mode")
> +      (if_then_else (eq (symbol_ref "<MODE>mode == DImode") (const_int 0))
> +       (const_string "SI")
> +       (const_string "DI")))])
>
>  ;; Subtract instructions

I don't think this pattern is correct.  See:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49281


H.J.

  parent reply	other threads:[~2011-06-04 15:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-20 16:36 Jakub Jelinek
2011-04-20 17:51 ` Richard Henderson
2011-04-21 13:01   ` Jakub Jelinek
2011-06-04 15:20 ` H.J. Lu [this message]
2011-06-04 15:40   ` Jakub Jelinek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='BANLkTinhGA=AzSkLuyrBXBDpmU48SSnY2w@mail.gmail.com' \
    --to=hjl.tools@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=ubizjak@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).