Another patch for PR88282

Message ID ca454f99-19ab-8f40-d635-7a59e2c88369@redhat.com
State New
Headers show
Series
  • Another patch for PR88282
Related show

Commit Message

Vladimir Makarov Dec. 6, 2018, 6:44 p.m.
Here is another solution for

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88282

   less hackish than original one.

   The patch was bootstrapped and tested on x86/x86-64/ppc64/aarch64.

   Committed as rev. 266862.

Comments

Richard Sandiford Dec. 7, 2018, 11:38 a.m. | #1
Vladimir Makarov <vmakarov@redhat.com> writes:
>    Here is another solution for

>

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88282

>

>    less hackish than original one.

>

>    The patch was bootstrapped and tested on x86/x86-64/ppc64/aarch64.

>

>    Committed as rev. 266862.


Nice!  Thanks for doing this.

Richard

Patch

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 266861)
+++ ChangeLog	(working copy)
@@ -1,3 +1,11 @@ 
+2018-12-06  Vladimir Makarov  <vmakarov@redhat.com>
+
+	PR target/88282
+	* ira.c (ira_init_register_move_cost): Use info from
+	hard_regno_mode_ok instead of contains_reg_of_mode.
+	* ira-costs.c (contains_reg_of_mode): Don't use cost from bigger
+	hard register class for some fixed hard registers.
+
 2018-12-06  Segher Boessenkool  <segher@kernel.crashing.org>
 
 	* doc/extend.texi (Using Assembly Language with C): Document asm inline.
Index: ira.c
===================================================================
--- ira.c	(revision 266861)
+++ ira.c	(working copy)
@@ -1573,11 +1573,17 @@  ira_init_register_move_cost (machine_mod
 {
   static unsigned short last_move_cost[N_REG_CLASSES][N_REG_CLASSES];
   bool all_match = true;
-  unsigned int cl1, cl2;
+  unsigned int i, cl1, cl2;
+  HARD_REG_SET ok_regs;
 
   ira_assert (ira_register_move_cost[mode] == NULL
 	      && ira_may_move_in_cost[mode] == NULL
 	      && ira_may_move_out_cost[mode] == NULL);
+  CLEAR_HARD_REG_SET (ok_regs);
+  for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
+    if (targetm.hard_regno_mode_ok (i, mode))
+      SET_HARD_REG_BIT (ok_regs, i);
+
   /* Note that we might be asked about the move costs of modes that
      cannot be stored in any hard register, for example if an inline
      asm tries to create a register operand with an impossible mode.
@@ -1586,8 +1592,8 @@  ira_init_register_move_cost (machine_mod
     for (cl2 = 0; cl2 < N_REG_CLASSES; cl2++)
       {
 	int cost;
-	if (!contains_reg_of_mode[cl1][mode]
-	    || !contains_reg_of_mode[cl2][mode])
+	if (!hard_reg_set_intersect_p (ok_regs, reg_class_contents[cl1])
+	    || !hard_reg_set_intersect_p (ok_regs, reg_class_contents[cl2]))
 	  {
 	    if ((ira_reg_class_max_nregs[cl1][mode]
 		 > ira_class_hard_regs_num[cl1])
Index: ira-costs.c
===================================================================
--- ira-costs.c	(revision 266784)
+++ ira-costs.c	(working copy)
@@ -1323,14 +1323,6 @@  record_operand_costs (rtx_insn *insn, en
 	  move_costs = ira_register_move_cost[mode];
 	  hard_reg_class = REGNO_REG_CLASS (other_regno);
 	  bigger_hard_reg_class = ira_pressure_class_translate[hard_reg_class];
-	  if (bigger_hard_reg_class == NO_REGS
-	      && (other_regno == STACK_POINTER_REGNUM
-#ifdef STATIC_CHAIN_REGNUM
-		  || other_regno == STATIC_CHAIN_REGNUM
-#endif
-		  || other_regno == FRAME_POINTER_REGNUM
-		  || other_regno == HARD_FRAME_POINTER_REGNUM))
-	    bigger_hard_reg_class = GENERAL_REGS;
 	  /* Target code may return any cost for mode which does not
 	     fit the the hard reg class (e.g. DImode for AREG on
 	     i386).  Check this and use a bigger class to get the
@@ -1345,17 +1337,6 @@  record_operand_costs (rtx_insn *insn, en
 	      cost = (i == 0
 		      ? move_costs[hard_reg_class][rclass]
 		      : move_costs[rclass][hard_reg_class]);
-	      /* Target code might define wrong big costs for smaller
-		 reg classes or reg classes containing only fixed hard
-		 regs.  Try a bigger class.  */
-	      if (bigger_hard_reg_class != hard_reg_class)
-		{
-		  int cost2 = (i == 0
-			       ? move_costs[bigger_hard_reg_class][rclass]
-			       : move_costs[rclass][bigger_hard_reg_class]);
-		  if (cost2 < cost)
-		    cost = cost2;
-		}
 	      
 	      op_costs[i]->cost[k] = cost * frequency;
 	      /* If we have assigned a class to this allocno in our