diff mbox

[11/50] Faster for_each_rtx-like iterators

Message ID 87mwblbrtn.fsf@googlemail.com
State New
Headers show

Commit Message

Richard Sandiford Aug. 3, 2014, 1:55 p.m. UTC
The order of the arguments matches canon_anti_dependence rather than
the order of the old structure fields.


gcc/
	* cse.c (check_dependence_data): Delete.
	(check_dependence): Change from being a for_each_rtx callback to being
	a function that examines all subrtxes itself.  Don't handle null rtxes.
	(invalidate): Update call accordingly.

Comments

Jeff Law Aug. 6, 2014, 6:20 p.m. UTC | #1
On 08/03/14 07:55, Richard Sandiford wrote:
> The order of the arguments matches canon_anti_dependence rather than
> the order of the old structure fields.
>
>
> gcc/
> 	* cse.c (check_dependence_data): Delete.
> 	(check_dependence): Change from being a for_each_rtx callback to being
> 	a function that examines all subrtxes itself.  Don't handle null rtxes.
> 	(invalidate): Update call accordingly.
OK.
jeff
diff mbox

Patch

Index: gcc/cse.c
===================================================================
--- gcc/cse.c	2014-08-03 11:25:22.876082343 +0100
+++ gcc/cse.c	2014-08-03 11:25:23.180085349 +0100
@@ -600,7 +600,6 @@  static int check_for_label_ref (rtx *, v
 extern void dump_class (struct table_elt*);
 static void get_cse_reg_info_1 (unsigned int regno);
 static struct cse_reg_info * get_cse_reg_info (unsigned int regno);
-static int check_dependence (rtx *, void *);
 
 static void flush_hash_table (void);
 static bool insn_live_p (rtx, int *);
@@ -1816,22 +1815,20 @@  flush_hash_table (void)
       }
 }
 
-/* Function called for each rtx to check whether an anti dependence exist.  */
-struct check_dependence_data
-{
-  enum machine_mode mode;
-  rtx exp;
-  rtx addr;
-};
+/* Check whether an anti dependence exists between X and EXP.  MODE and
+   ADDR are as for canon_anti_dependence.  */
 
-static int
-check_dependence (rtx *x, void *data)
+static bool
+check_dependence (const_rtx x, rtx exp, enum machine_mode mode, rtx addr)
 {
-  struct check_dependence_data *d = (struct check_dependence_data *) data;
-  if (*x && MEM_P (*x))
-    return canon_anti_dependence (*x, true, d->exp, d->mode, d->addr);
-  else
-    return 0;
+  subrtx_iterator::array_type array;
+  FOR_EACH_SUBRTX (iter, array, x, NONCONST)
+    {
+      const_rtx x = *iter;
+      if (MEM_P (x) && canon_anti_dependence (x, true, exp, mode, addr))
+	return true;
+    }
+  return false;
 }
 
 /* Remove from the hash table, or mark as invalid, all expressions whose
@@ -1952,18 +1949,13 @@  invalidate (rtx x, enum machine_mode ful
 	      next = p->next_same_hash;
 	      if (p->in_memory)
 		{
-		  struct check_dependence_data d;
-
 		  /* Just canonicalize the expression once;
 		     otherwise each time we call invalidate
 		     true_dependence will canonicalize the
 		     expression again.  */
 		  if (!p->canon_exp)
 		    p->canon_exp = canon_rtx (p->exp);
-		  d.exp = x;
-		  d.addr = addr;
-		  d.mode = full_mode;
-		  if (for_each_rtx (&p->canon_exp, check_dependence, &d))
+		  if (check_dependence (p->canon_exp, x, full_mode, addr))
 		    remove_from_table (p, i);
 		}
 	    }