public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@gmail.com>
To: Segher Boessenkool <segher@kernel.crashing.org>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH 5/8] [RS6000] rs6000_rtx_costs cost IOR
Date: Fri, 22 Jan 2021 09:40:00 +1030	[thread overview]
Message-ID: <20210121231000.GH26219@bubble.grove.modra.org> (raw)
In-Reply-To: <20210112033218.GC26219@bubble.grove.modra.org>

Ping.

On Tue, Jan 12, 2021 at 02:02:18PM +1030, Alan Modra wrote:
> Ping
> https://gcc.gnu.org/pipermail/gcc-patches/2020-October/555756.html
> 
> On Thu, Oct 08, 2020 at 09:27:57AM +1030, Alan Modra wrote:
> > 	* config/rs6000/rs6000.c (rotate_insert_cost): New function.
> > 	(rs6000_rtx_costs): Cost IOR.
> > 
> > diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
> > index 383d2901c9f..15a806fe307 100644
> > --- a/gcc/config/rs6000/rs6000.c
> > +++ b/gcc/config/rs6000/rs6000.c
> > @@ -21206,6 +21206,91 @@ rs6000_cannot_copy_insn_p (rtx_insn *insn)
> >  	 && get_attr_cannot_copy (insn);
> >  }
> >  
> > +/* Handle rtx_costs for scalar integer rotate and insert insns.  */
> > +
> > +static bool
> > +rotate_insert_cost (rtx left, rtx right, machine_mode mode, bool speed,
> > +		    int *total)
> > +{
> > +  if (GET_CODE (right) == AND
> > +      && CONST_INT_P (XEXP (right, 1))
> > +      && UINTVAL (XEXP (left, 1)) + UINTVAL (XEXP (right, 1)) + 1 == 0)
> > +    {
> > +      rtx leftop = XEXP (left, 0);
> > +      rtx rightop = XEXP (right, 0);
> > +
> > +      /* rotlsi3_insert_5.  */
> > +      if (REG_P (leftop)
> > +	  && REG_P (rightop)
> > +	  && mode == SImode
> > +	  && UINTVAL (XEXP (left, 1)) != 0
> > +	  && UINTVAL (XEXP (right, 1)) != 0
> > +	  && rs6000_is_valid_mask (XEXP (left, 1), NULL, NULL, mode))
> > +	return true;
> > +      /* rotldi3_insert_6.  */
> > +      if (REG_P (leftop)
> > +	  && REG_P (rightop)
> > +	  && mode == DImode
> > +	  && exact_log2 (-UINTVAL (XEXP (left, 1))) > 0)
> > +	return true;
> > +      /* rotldi3_insert_7.  */
> > +      if (REG_P (leftop)
> > +	  && REG_P (rightop)
> > +	  && mode == DImode
> > +	  && exact_log2 (-UINTVAL (XEXP (right, 1))) > 0)
> > +	return true;
> > +
> > +      rtx mask = 0;
> > +      rtx shift = leftop;
> > +      rtx_code shift_code = GET_CODE (shift);
> > +      /* rotl<mode>3_insert.  */
> > +      if (shift_code == ROTATE
> > +	  || shift_code == ASHIFT
> > +	  || shift_code == LSHIFTRT)
> > +	mask = right;
> > +      else
> > +	{
> > +	  shift = rightop;
> > +	  shift_code = GET_CODE (shift);
> > +	  /* rotl<mode>3_insert_2.  */
> > +	  if (shift_code == ROTATE
> > +	      || shift_code == ASHIFT
> > +	      || shift_code == LSHIFTRT)
> > +	    mask = left;
> > +	}
> > +      if (mask
> > +	  && CONST_INT_P (XEXP (shift, 1))
> > +	  && rs6000_is_valid_insert_mask (XEXP (mask, 1), shift, mode))
> > +	{
> > +	  *total += rtx_cost (XEXP (shift, 0), mode, shift_code, 0, speed);
> > +	  *total += rtx_cost (XEXP (mask, 0), mode, AND, 0, speed);
> > +	  return true;
> > +	}
> > +    }
> > +  /* rotl<mode>3_insert_3.  */
> > +  if (GET_CODE (right) == ASHIFT
> > +      && CONST_INT_P (XEXP (right, 1))
> > +      && (INTVAL (XEXP (right, 1))
> > +	  == exact_log2 (UINTVAL (XEXP (left, 1)) + 1)))
> > +    {
> > +      *total += rtx_cost (XEXP (left, 0), mode, AND, 0, speed);
> > +      *total += rtx_cost (XEXP (right, 0), mode, ASHIFT, 0, speed);
> > +      return true;
> > +    }
> > +  /* rotl<mode>3_insert_4.  */
> > +  if (GET_CODE (right) == LSHIFTRT
> > +      && CONST_INT_P (XEXP (right, 1))
> > +      && mode == SImode
> > +      && (INTVAL (XEXP (right, 1))
> > +	  + exact_log2 (-UINTVAL (XEXP (left, 1)))) == 32)
> > +    {
> > +      *total += rtx_cost (XEXP (left, 0), mode, AND, 0, speed);
> > +      *total += rtx_cost (XEXP (right, 0), mode, LSHIFTRT, 0, speed);
> > +      return true;
> > +    }
> > +  return false;
> > +}
> > +
> >  /* Compute a (partial) cost for rtx X.  Return true if the complete
> >     cost has been computed, and false if subexpressions should be
> >     scanned.  In either case, *TOTAL contains the cost result.
> > @@ -21253,7 +21338,7 @@ static bool
> >  rs6000_rtx_costs (rtx x, machine_mode mode, int outer_code,
> >  		  int opno ATTRIBUTE_UNUSED, int *total, bool speed)
> >  {
> > -  rtx right;
> > +  rtx left, right;
> >    int code = GET_CODE (x);
> >  
> >    switch (code)
> > @@ -21435,7 +21520,7 @@ rs6000_rtx_costs (rtx x, machine_mode mode, int outer_code,
> >        right = XEXP (x, 1);
> >        if (CONST_INT_P (right))
> >  	{
> > -	  rtx left = XEXP (x, 0);
> > +	  left = XEXP (x, 0);
> >  	  rtx_code left_code = GET_CODE (left);
> >  
> >  	  /* rotate-and-mask: 1 insn.  */
> > @@ -21452,9 +21537,16 @@ rs6000_rtx_costs (rtx x, machine_mode mode, int outer_code,
> >        return false;
> >  
> >      case IOR:
> > -      /* FIXME */
> >        *total = COSTS_N_INSNS (1);
> > -      return true;
> > +      left = XEXP (x, 0);
> > +      if (GET_CODE (left) == AND
> > +	  && CONST_INT_P (XEXP (left, 1)))
> > +	{
> > +	  right = XEXP (x, 1);
> > +	  if (rotate_insert_cost (left, right, mode, speed, total))
> > +	    return true;
> > +	}
> > +      return false;
> >  
> >      case CLZ:
> >      case XOR:

-- 
Alan Modra
Australia Development Lab, IBM

  parent reply	other threads:[~2021-01-21 23:10 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-07 22:57 [PATCH 0/8] [RS6000] rs6000_rtx_costs V2 Alan Modra
2020-10-07 22:57 ` [PATCH 1/8] [RS6000] rs6000_rtx_costs comment Alan Modra
2020-10-14 20:08   ` Segher Boessenkool
2020-10-07 22:57 ` [PATCH 2/8] [RS6000] rs6000_rtx_costs for AND Alan Modra
2020-10-20 18:55   ` Segher Boessenkool
2020-10-21  2:57     ` Alan Modra
2020-10-21 20:29       ` Segher Boessenkool
2020-10-21 22:11         ` Alan Modra
2020-10-22 13:29           ` Segher Boessenkool
2020-10-23 23:18           ` Hans-Peter Nilsson
2020-10-24  1:04             ` Alan Modra
2020-10-07 22:57 ` [PATCH 3/8] [RS6000] rs6000_rtx_costs tidy AND Alan Modra
     [not found]   ` <20210112033157.GA26219@bubble.grove.modra.org>
2021-01-21 23:09     ` Alan Modra
2021-01-25 22:37   ` Segher Boessenkool
2021-02-01  2:06     ` Alan Modra
2020-10-07 22:57 ` [PATCH 4/8] [RS6000] rs6000_rtx_costs tidy break/return Alan Modra
     [not found]   ` <20210112033209.GB26219@bubble.grove.modra.org>
2021-01-21 23:09     ` Alan Modra
2021-01-25 22:40   ` Segher Boessenkool
2020-10-07 22:57 ` [PATCH 5/8] [RS6000] rs6000_rtx_costs cost IOR Alan Modra
     [not found]   ` <20210112033218.GC26219@bubble.grove.modra.org>
2021-01-21 23:10     ` Alan Modra [this message]
2021-01-25 22:51   ` Segher Boessenkool
2021-02-01  2:13     ` Alan Modra
2020-10-07 22:57 ` [PATCH 6/8] [RS6000] rs6000_rtx_costs multi-insn constants Alan Modra
2020-10-07 22:57 ` [PATCH 7/8] [RS6000] rs6000_rtx_costs reduce cost for SETs Alan Modra
2020-10-08 18:19   ` will schmidt
     [not found]   ` <20210112033227.GD26219@bubble.grove.modra.org>
2021-01-21 23:10     ` Alan Modra
2020-10-07 22:58 ` [PATCH 8/8] [RS6000] rs6000_rtx_costs for !speed Alan Modra
     [not found]   ` <20210112033236.GE26219@bubble.grove.modra.org>
2021-01-21 23:11     ` Alan Modra
2020-12-05  9:12 ` [PATCH 0/8] [RS6000] rs6000_rtx_costs V2 Alan Modra
2021-01-11 21:42   ` Alan Modra

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=20210121231000.GH26219@bubble.grove.modra.org \
    --to=amodra@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=segher@kernel.crashing.org \
    /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).