diff mbox

[02/50] alias.c:refs_newer_value_p

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

Commit Message

Richard Sandiford Aug. 3, 2014, 1:40 p.m. UTC
gcc/
	* alias.c: Include rtl-iter.h.
	(refs_newer_value_cb): Delete.
	(refs_newer_value_p): Use FOR_EACH_SUBRTX instead of for_each_rtx.

Comments

Jeff Law Aug. 5, 2014, 8:52 p.m. UTC | #1
On 08/03/14 07:40, Richard Sandiford wrote:
> gcc/
> 	* alias.c: Include rtl-iter.h.
> 	(refs_newer_value_cb): Delete.
> 	(refs_newer_value_p): Use FOR_EACH_SUBRTX instead of for_each_rtx.
OK.

Just a few notes.

1. I really like when we can make these callbacks go away :-)

2. When the callbacks go away, the opaque data we pass them goes away as 
well which is good for readability.

3. That opaque data is often a local and we had to take its address and 
thus force it to memory.  With the direct uses in the updated code those 
locals don't have to live in memory, which is goodness.

Anyway, just wanted to point those out for anyone looking at this in 
parallel or in the future.

jeff
diff mbox

Patch

Index: gcc/alias.c
===================================================================
--- gcc/alias.c	2014-08-03 11:25:10.551960499 +0100
+++ gcc/alias.c	2014-08-03 11:25:20.611059950 +0100
@@ -48,6 +48,7 @@  Software Foundation; either version 3, o
 #include "is-a.h"
 #include "gimple.h"
 #include "gimple-ssa.h"
+#include "rtl-iter.h"
 
 /* The aliasing API provided here solves related but different problems:
 
@@ -1853,27 +1854,18 @@  base_alias_check (rtx x, rtx x_base, rtx
   return 1;
 }
 
-/* Callback for for_each_rtx, that returns 1 upon encountering a VALUE
-   whose UID is greater than the int uid that D points to.  */
-
-static int
-refs_newer_value_cb (rtx *x, void *d)
-{
-  if (GET_CODE (*x) == VALUE && CSELIB_VAL_PTR (*x)->uid > *(int *)d)
-    return 1;
-
-  return 0;
-}
-
 /* Return TRUE if EXPR refers to a VALUE whose uid is greater than
    that of V.  */
 
 static bool
-refs_newer_value_p (rtx expr, rtx v)
+refs_newer_value_p (const_rtx expr, rtx v)
 {
   int minuid = CSELIB_VAL_PTR (v)->uid;
-
-  return for_each_rtx (&expr, refs_newer_value_cb, &minuid);
+  subrtx_iterator::array_type array;
+  FOR_EACH_SUBRTX (iter, array, expr, NONCONST)
+    if (GET_CODE (*iter) == VALUE && CSELIB_VAL_PTR (*iter)->uid > minuid)
+      return true;
+  return false;
 }
 
 /* Convert the address X into something we can use.  This is done by returning