diff mbox series

hppa64: Improve hppa_rtx_costs for DImode shifts by constants.

Message ID 006f01d68551$716332e0$542998a0$@nextmovesoftware.com
State New
Headers show
Series hppa64: Improve hppa_rtx_costs for DImode shifts by constants. | expand

Commit Message

Roger Sayle Sept. 7, 2020, 7:59 p.m. UTC
Hi Dave,
Here's another patch for you to try on hppa64.  I've no idea whether it
helps PR middle-end/87256 on hppa64 or makes things worse, but this
updates the DImode shift by constant costs on TARGET_64BIT, in the
same way that the previous rtx_costs patch improved the SImode costs.
Generating optimal code is a useful pre-requisite.  If nothing else, this
should reduce the number PA2.0 instructions generated for PR87256's
hog.c.

Please let me know what you think.


2020-09-07  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
	* config/pa/pa.c (hppa_rtx_costs) [ASHIFT, ASHIFTRT, LSHIFTRT]:
	Provide accurate costs for DImode shifts of integer constants.


Many thanks in advance,
Roger
--

Comments

John David Anglin Sept. 7, 2020, 8:25 p.m. UTC | #1
On 2020-09-07 3:59 p.m., Roger Sayle wrote:
> Please let me know what you think.
>
>
> 2020-09-07  Roger Sayle  <roger@nextmovesoftware.com>
>
> gcc/ChangeLog
> 	* config/pa/pa.c (hppa_rtx_costs) [ASHIFT, ASHIFTRT, LSHIFTRT]:
> 	Provide accurate costs for DImode shifts of integer constants.
Will do.

I'm still testing patchh3.txt on hppa64-hpux.  Takes a bit of time to do full build and check.

Thanks,
Dave
John David Anglin Sept. 13, 2020, 6:58 p.m. UTC | #2
Hi Roger,

On 2020-09-07 3:59 p.m., Roger Sayle wrote:
> 2020-09-07  Roger Sayle  <roger@nextmovesoftware.com>
>
> gcc/ChangeLog
> 	* config/pa/pa.c (hppa_rtx_costs) [ASHIFT, ASHIFTRT, LSHIFTRT]:
> 	Provide accurate costs for DImode shifts of integer constants.
I committed this change.  However, it doesn't fix PR middle-end/87256 on hppa64.

Regards,
Dave
diff mbox series

Patch

diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c
index a9223ab..210e44f 100644
--- a/gcc/config/pa/pa.c
+++ b/gcc/config/pa/pa.c
@@ -1630,13 +1630,16 @@  hppa_rtx_costs (rtx x, machine_mode mode, int outer_code,
     case ASHIFT:
       if (mode == DImode)
 	{
-	  if (TARGET_64BIT)
-	    *total = COSTS_N_INSNS (3);
-	  else if (REG_P (XEXP (x, 0)) && CONST_INT_P (XEXP (x, 1)))
+	  if (REG_P (XEXP (x, 0)) && CONST_INT_P (XEXP (x, 1)))
 	    {
-	      *total = COSTS_N_INSNS (2);
+	      if (TARGET_64BIT)
+		*total = COSTS_N_INSNS (1);
+	      else
+		*total = COSTS_N_INSNS (2);
 	      return true;
 	    }
+	  else if (TARGET_64BIT)
+	    *total = COSTS_N_INSNS (3);
 	  else if (speed)
 	    *total = COSTS_N_INSNS (13);
 	  else
@@ -1661,13 +1664,16 @@  hppa_rtx_costs (rtx x, machine_mode mode, int outer_code,
     case ASHIFTRT:
       if (mode == DImode)
 	{
-	  if (TARGET_64BIT)
-	    *total = COSTS_N_INSNS (3);
-	  else if (REG_P (XEXP (x, 0)) && CONST_INT_P (XEXP (x, 1)))
+	  if (REG_P (XEXP (x, 0)) && CONST_INT_P (XEXP (x, 1)))
 	    {
-	      *total = COSTS_N_INSNS (2);
+	      if (TARGET_64BIT)
+		*total = COSTS_N_INSNS (1);
+	      else
+		*total = COSTS_N_INSNS (2);
 	      return true;
 	    }
+	  else if (TARGET_64BIT)
+	    *total = COSTS_N_INSNS (3);
 	  else if (speed)
 	    *total = COSTS_N_INSNS (14);
 	  else
@@ -1692,13 +1698,16 @@  hppa_rtx_costs (rtx x, machine_mode mode, int outer_code,
     case LSHIFTRT:
       if (mode == DImode)
 	{
-	  if (TARGET_64BIT)
-	    *total = COSTS_N_INSNS (2);
-	  else if (REG_P (XEXP (x, 0)) && CONST_INT_P (XEXP (x, 1)))
+	  if (REG_P (XEXP (x, 0)) && CONST_INT_P (XEXP (x, 1)))
 	    {
-	      *total = COSTS_N_INSNS (2);
+	      if (TARGET_64BIT)
+		*total = COSTS_N_INSNS (1);
+	      else
+		*total = COSTS_N_INSNS (2);
 	      return true;
 	    }
+	  else if (TARGET_64BIT)
+	    *total = COSTS_N_INSNS (2);
 	  else if (speed)
 	    *total = COSTS_N_INSNS (12);
 	  else