[8/9] Remove hard_reg_set_equal_p
diff mbox series

Message ID mptv9u1791a.fsf@arm.com
State New
Headers show
Series
  • Make HARD_REG_SETs easier to use
Related show

Commit Message

Richard Sandiford Sept. 9, 2019, 4:02 p.m. UTC
Use "x == y" instead of "hard_reg_set_equal_p (x, y)".


2019-09-09  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
	* hard-reg-set.h (HARD_REG_SET::operator==): New function.
	(HARD_REG_SET::operator!=): Likewise.
	(hard_reg_set_equal_p): Delete.
	* cfgcleanup.c (old_insns_match_p): Use == instead of
	hard_reg_set_equal_p and != instead of !hard_reg_set_equal_p.
	* ira-color.c (allocno_hard_regs_hasher::equal): Likewise.
	(add_allocno_hard_regs_to_forest): Likewise.
	(setup_allocno_available_regs_num): Likewise.
	* ira.c (setup_pressure_classes): Likewise.
	(setup_allocno_and_important_classes): Likewise.
	(setup_reg_class_relations): Likewise.
	* lra-lives.c (process_bb_lives): Likewise.
	* reg-stack.c (change_stack, convert_regs_1): Likewise.

Comments

Jeff Law Sept. 9, 2019, 5:41 p.m. UTC | #1
On 9/9/19 10:02 AM, Richard Sandiford wrote:
> Use "x == y" instead of "hard_reg_set_equal_p (x, y)".
> 
> 
> 2019-09-09  Richard Sandiford  <richard.sandiford@arm.com>
> 
> gcc/
> 	* hard-reg-set.h (HARD_REG_SET::operator==): New function.
> 	(HARD_REG_SET::operator!=): Likewise.
> 	(hard_reg_set_equal_p): Delete.
> 	* cfgcleanup.c (old_insns_match_p): Use == instead of
> 	hard_reg_set_equal_p and != instead of !hard_reg_set_equal_p.
> 	* ira-color.c (allocno_hard_regs_hasher::equal): Likewise.
> 	(add_allocno_hard_regs_to_forest): Likewise.
> 	(setup_allocno_available_regs_num): Likewise.
> 	* ira.c (setup_pressure_classes): Likewise.
> 	(setup_allocno_and_important_classes): Likewise.
> 	(setup_reg_class_relations): Likewise.
> 	* lra-lives.c (process_bb_lives): Likewise.
> 	* reg-stack.c (change_stack, convert_regs_1): Likewise.
> 
OK
jeff

Patch
diff mbox series

Index: gcc/hard-reg-set.h
===================================================================
--- gcc/hard-reg-set.h	2019-09-09 16:10:50.379298529 +0100
+++ gcc/hard-reg-set.h	2019-09-09 16:11:16.431114836 +0100
@@ -96,6 +96,21 @@  struct HARD_REG_SET
     return *this;
   }
 
+  bool
+  operator== (const HARD_REG_SET &other) const
+  {
+    HARD_REG_ELT_TYPE bad = 0;
+    for (unsigned int i = 0; i < ARRAY_SIZE (elts); ++i)
+      bad |= (elts[i] ^ other.elts[i]);
+    return bad == 0;
+  }
+
+  bool
+  operator!= (const HARD_REG_SET &other) const
+  {
+    return !operator== (other);
+  }
+
   HARD_REG_ELT_TYPE elts[HARD_REG_SET_LONGS];
 };
 typedef const HARD_REG_SET &const_hard_reg_set;
@@ -129,7 +144,6 @@  #define HARD_CONST(X) ((HARD_REG_ELT_TYP
    Also define:
 
    hard_reg_set_subset_p (X, Y), which returns true if X is a subset of Y.
-   hard_reg_set_equal_p (X, Y), which returns true if X and Y are equal.
    hard_reg_set_intersect_p (X, Y), which returns true if X and Y intersect.
    hard_reg_set_empty_p (X), which returns true if X is empty.  */
 
@@ -154,12 +168,6 @@  hard_reg_set_subset_p (const_hard_reg_se
 }
 
 static inline bool
-hard_reg_set_equal_p (const_hard_reg_set x, const_hard_reg_set y)
-{
-  return x == y;
-}
-
-static inline bool
 hard_reg_set_intersect_p (const_hard_reg_set x, const_hard_reg_set y)
 {
   return (x & y) != HARD_CONST (0);
@@ -217,15 +225,6 @@  hard_reg_set_subset_p (const_hard_reg_se
   return bad == 0;
 }
 
-static inline bool
-hard_reg_set_equal_p (const_hard_reg_set x, const_hard_reg_set y)
-{
-  HARD_REG_ELT_TYPE bad = 0;
-  for (unsigned int i = 0; i < ARRAY_SIZE (x.elts); ++i)
-    bad |= (x.elts[i] ^ y.elts[i]);
-  return bad == 0;
-}
-
 static inline bool
 hard_reg_set_intersect_p (const_hard_reg_set x, const_hard_reg_set y)
 {
Index: gcc/cfgcleanup.c
===================================================================
--- gcc/cfgcleanup.c	2019-07-18 09:23:02.893376178 +0100
+++ gcc/cfgcleanup.c	2019-09-09 16:11:16.431114836 +0100
@@ -1231,7 +1231,7 @@  old_insns_match_p (int mode ATTRIBUTE_UN
       get_call_reg_set_usage (i1, &i1_used, call_used_reg_set);
       get_call_reg_set_usage (i2, &i2_used, call_used_reg_set);
 
-      if (!hard_reg_set_equal_p (i1_used, i2_used))
+      if (i1_used != i2_used)
         return dir_none;
     }
 
@@ -1265,7 +1265,7 @@  old_insns_match_p (int mode ATTRIBUTE_UN
 	if (REG_NOTE_KIND (note) == REG_DEAD && STACK_REG_P (XEXP (note, 0)))
 	  SET_HARD_REG_BIT (i2_regset, REGNO (XEXP (note, 0)));
 
-      if (!hard_reg_set_equal_p (i1_regset, i2_regset))
+      if (i1_regset != i2_regset)
 	return dir_none;
     }
 #endif
Index: gcc/ira-color.c
===================================================================
--- gcc/ira-color.c	2019-09-09 16:10:15.303545844 +0100
+++ gcc/ira-color.c	2019-09-09 16:11:16.431114836 +0100
@@ -218,7 +218,7 @@  allocno_hard_regs_hasher::hash (const al
 allocno_hard_regs_hasher::equal (const allocno_hard_regs *hv1,
 				 const allocno_hard_regs *hv2)
 {
-  return hard_reg_set_equal_p (hv1->set, hv2->set);
+  return hv1->set == hv2->set;
 }
 
 /* Hash table of unique allocno hard registers.  */
@@ -371,7 +371,7 @@  add_allocno_hard_regs_to_forest (allocno
   start = hard_regs_node_vec.length ();
   for (node = *roots; node != NULL; node = node->next)
     {
-      if (hard_reg_set_equal_p (hv->set, node->hard_regs->set))
+      if (hv->set == node->hard_regs->set)
 	return;
       if (hard_reg_set_subset_p (hv->set, node->hard_regs->set))
 	{
@@ -2688,8 +2688,7 @@  setup_allocno_available_regs_num (ira_al
      reg_class_names[aclass], ira_class_hard_regs_num[aclass], n);
   print_hard_reg_set (ira_dump_file, data->profitable_hard_regs, false);
   fprintf (ira_dump_file, ", %snode: ",
-	   hard_reg_set_equal_p (data->profitable_hard_regs,
-				 data->hard_regs_node->hard_regs->set)
+	   data->profitable_hard_regs == data->hard_regs_node->hard_regs->set
 	   ? "" : "^");
   print_hard_reg_set (ira_dump_file,
 		      data->hard_regs_node->hard_regs->set, false);
Index: gcc/ira.c
===================================================================
--- gcc/ira.c	2019-09-09 16:10:50.379298529 +0100
+++ gcc/ira.c	2019-09-09 16:11:16.431114836 +0100
@@ -841,8 +841,7 @@  setup_pressure_classes (void)
 	      temp_hard_regset2 = (reg_class_contents[cl2]
 				   & ~no_unit_alloc_regs);
 	      if (hard_reg_set_subset_p (temp_hard_regset, temp_hard_regset2)
-		  && (! hard_reg_set_equal_p (temp_hard_regset,
-					      temp_hard_regset2)
+		  && (temp_hard_regset != temp_hard_regset2
 		      || cl2 == (int) GENERAL_REGS))
 		{
 		  pressure_classes[curr++] = (enum reg_class) cl2;
@@ -850,11 +849,10 @@  setup_pressure_classes (void)
 		  continue;
 		}
 	      if (hard_reg_set_subset_p (temp_hard_regset2, temp_hard_regset)
-		  && (! hard_reg_set_equal_p (temp_hard_regset2,
-					      temp_hard_regset)
+		  && (temp_hard_regset2 != temp_hard_regset
 		      || cl == (int) GENERAL_REGS))
 		continue;
-	      if (hard_reg_set_equal_p (temp_hard_regset2, temp_hard_regset))
+	      if (temp_hard_regset2 == temp_hard_regset)
 		insert_p = false;
 	      pressure_classes[curr++] = (enum reg_class) cl2;
 	    }
@@ -999,8 +997,7 @@  setup_allocno_and_important_classes (voi
 	{
 	  cl = classes[j];
 	  temp_hard_regset2 = reg_class_contents[cl] & ~no_unit_alloc_regs;
-	  if (hard_reg_set_equal_p (temp_hard_regset,
-				    temp_hard_regset2))
+	  if (temp_hard_regset == temp_hard_regset2)
 	    break;
 	}
       if (j >= n || targetm.additional_allocno_class_p (i))
@@ -1273,7 +1270,7 @@  setup_reg_class_relations (void)
 			     the same, prefer GENERAL_REGS or the
 			     smallest class for debugging
 			     purposes.  */
-			  || (hard_reg_set_equal_p (temp_hard_regset, temp_set2)
+			  || (temp_hard_regset == temp_set2
 			      && (cl3 == GENERAL_REGS
 				  || ((ira_reg_class_intersect[cl1][cl2]
 				       != GENERAL_REGS)
@@ -1290,7 +1287,7 @@  setup_reg_class_relations (void)
 		  if (! hard_reg_set_subset_p (temp_hard_regset, temp_set2)
 		      /* Ignore unavailable hard registers and prefer
 			 smallest class for debugging purposes.  */
-		      || (hard_reg_set_equal_p (temp_hard_regset, temp_set2)
+		      || (temp_hard_regset == temp_set2
 			  && hard_reg_set_subset_p
 			     (reg_class_contents[cl3],
 			      reg_class_contents
@@ -1309,8 +1306,7 @@  setup_reg_class_relations (void)
 	 	  if (ira_reg_class_subunion[cl1][cl2] == NO_REGS
 		      || (hard_reg_set_subset_p (temp_set2, temp_hard_regset)
 			  
-			  && (! hard_reg_set_equal_p (temp_set2,
-						      temp_hard_regset)
+			  && (temp_set2 != temp_hard_regset
 			      || cl3 == GENERAL_REGS
 			      /* If the allocatable hard register sets are the
 				 same, prefer GENERAL_REGS or the smallest
@@ -1333,8 +1329,7 @@  setup_reg_class_relations (void)
 	 	  if (ira_reg_class_superunion[cl1][cl2] == NO_REGS
 		      || (hard_reg_set_subset_p (temp_hard_regset, temp_set2)
 
-			  && (! hard_reg_set_equal_p (temp_set2,
-						      temp_hard_regset)
+			  && (temp_set2 != temp_hard_regset
 			      || cl3 == GENERAL_REGS
 			      /* If the allocatable hard register sets are the
 				 same, prefer GENERAL_REGS or the smallest
Index: gcc/lra-lives.c
===================================================================
--- gcc/lra-lives.c	2019-09-09 16:10:15.307545816 +0100
+++ gcc/lra-lives.c	2019-09-09 16:11:16.435114808 +0100
@@ -936,8 +936,8 @@  process_bb_lives (basic_block bb, int &c
 				      call_used_reg_set);
 
 	      bool flush = (! hard_reg_set_empty_p (last_call_used_reg_set)
-			    && ( ! hard_reg_set_equal_p (last_call_used_reg_set,
-						       this_call_used_reg_set)))
+			    && (last_call_used_reg_set
+				!= this_call_used_reg_set))
 			   || (last_call_insn && ! calls_have_same_clobbers_p
 						     (call_insn,
 						      last_call_insn));
Index: gcc/reg-stack.c
===================================================================
--- gcc/reg-stack.c	2019-09-09 16:06:17.653228374 +0100
+++ gcc/reg-stack.c	2019-09-09 16:11:16.435114808 +0100
@@ -2643,7 +2643,7 @@  change_stack (rtx_insn *insn, stack_ptr
       /* By now, the only difference should be the order of the stack,
 	 not their depth or liveliness.  */
 
-      gcc_assert (hard_reg_set_equal_p (old->reg_set, new_stack->reg_set));
+      gcc_assert (old->reg_set == new_stack->reg_set);
       gcc_assert (old->top == new_stack->top);
 
       /* If the stack is not empty (new_stack->top != -1), loop here emitting
@@ -3158,8 +3158,7 @@  convert_regs_1 (basic_block block)
      asms, we zapped the instruction itself, but that didn't produce the
      same pattern of register kills as before.  */
 
-  gcc_assert (hard_reg_set_equal_p (regstack.reg_set, bi->out_reg_set)
-	      || any_malformed_asm);
+  gcc_assert (regstack.reg_set == bi->out_reg_set || any_malformed_asm);
   bi->stack_out = regstack;
   bi->done = true;