From: Jakub Jelinek <jakub@redhat.com>
To: Richard Henderson <rth@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: Thu, 21 Apr 2011 13:01:00 -0000 [thread overview]
Message-ID: <20110421123320.GT17079@tyan-ft48-01.lab.bos.redhat.com> (raw)
In-Reply-To: <4DAF1788.7060306@redhat.com>
On Wed, Apr 20, 2011 at 10:27:36AM -0700, Richard Henderson wrote:
> On 04/20/2011 09:09 AM, Jakub Jelinek 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.
>
> Any chance you could do this in combine instead? Shift-and-add patterns
> are a fairly common architectural feature...
I've tried to do it in simplify-rtx.c, unfortunately combine.c does exactly
opposite canonicalization and thus it results in endless recursion:
/* If we are adding two things that have no bits in common, convert
the addition into an IOR. This will often be further simplified,
for example in cases like ((a & 1) + (a & 2)), which can
become a & 3. */
if (GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT
&& (nonzero_bits (XEXP (x, 0), mode)
& nonzero_bits (XEXP (x, 1), mode)) == 0)
{
/* Try to simplify the expression further. */
rtx tor = simplify_gen_binary (IOR, mode, XEXP (x, 0), XEXP (x, 1));
temp = combine_simplify_rtx (tor, mode, in_dest, 0);
/* If we could, great. If not, do not go ahead with the IOR
replacement, since PLUS appears in many special purpose
address arithmetic instructions. */
if (GET_CODE (temp) != CLOBBER && temp != tor)
return temp;
}
So at least it can't be done in simplify_binary_operation_1.
Jakub
next prev parent reply other threads:[~2011-04-21 12:33 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 [this message]
2011-06-04 15:20 ` H.J. Lu
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=20110421123320.GT17079@tyan-ft48-01.lab.bos.redhat.com \
--to=jakub@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=rth@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).