public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Segher Boessenkool <segher@kernel.crashing.org>
To: vogt@linux.vnet.ibm.com, gcc-patches@gcc.gnu.org,
	       Andreas Krebbel <krebbel@linux.vnet.ibm.com>
Subject: Re: [PATCH] combine: Omit redundant AND in change_zero_ext.
Date: Wed, 14 Dec 2016 19:55:00 -0000	[thread overview]
Message-ID: <20161214193248.GY30845@gate.crashing.org> (raw)
In-Reply-To: <20161214100147.GA3427@linux.vnet.ibm.com>

On Wed, Dec 14, 2016 at 11:01:47AM +0100, Dominik Vogt wrote:
> This is another micro-optimisation in change_zero_ext.  If an
> 
>   (and (lshiftrt ... (N)) (M))
> 
> generated by change_zero_ext is equivalent to just
> 
>   (lshiftrt ... (N))
> 
> (because the AND constant selects the N rightmost bits of the
> result), strip off the AND.
> 
> _But_ I'm still not completely convinced whether this is a good
> idea.  It may become necessary to add md patterns to deal with
> just the LSHIFTRT.  On the other hand it saves the need for
> another special case in change_zero_ext, and a less obvious, very
> specific risbg pattern on s390 

For PowerPC we should already have all such patterns with a "bare" shift
(they can be created in other ways, too).

> Bootstrapped and regression tested on s390x and s390.  (Targets
> with risbg-like instructions (Power, others?) may need some
> tuning.)

But, it is also possible I missed some.  So please wait until I have
tested it.


> diff --git a/gcc/combine.c b/gcc/combine.c
> index 19851a2..5ebf31c 100644
> --- a/gcc/combine.c
> +++ b/gcc/combine.c
> @@ -11280,8 +11280,13 @@ change_zero_ext (rtx pat)
>        else
>  	continue;
>  
> -      wide_int mask = wi::mask (size, false, GET_MODE_PRECISION (mode));
> -      x = gen_rtx_AND (mode, x, immed_wide_int_const (mask, mode));
> +      if (!(GET_CODE (x) == LSHIFTRT
> +	    && CONST_INT_P (XEXP (x, 1))
> +	    && size + INTVAL (XEXP (x, 1)) == GET_MODE_PRECISION (mode)))
> +	{
> +	  wide_int mask = wi::mask (size, false, GET_MODE_PRECISION (mode));
> +	  x = gen_rtx_AND (mode, x, immed_wide_int_const (mask, mode));
> +	}

One could argue that this should have been an lshiftrt in the first place
then, not a zero_ext*.  Hrm.


Segher

  reply	other threads:[~2016-12-14 19:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-14 10:15 Dominik Vogt
2016-12-14 19:55 ` Segher Boessenkool [this message]
2016-12-15  9:16   ` Dominik Vogt
2016-12-15  9:19     ` Segher Boessenkool
2016-12-19  9:57 ` Andreas Krebbel

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=20161214193248.GY30845@gate.crashing.org \
    --to=segher@kernel.crashing.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=krebbel@linux.vnet.ibm.com \
    --cc=vogt@linux.vnet.ibm.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).