Hi,
While looking for -Winline messages I noticed that sched-int.h has self 
recursive
function declared inline.  The recursion is tail recursion but we fail to 
recognize
it as such. The problem ist hat there is a local variable link whose address
is passed to function  &DEPS_LIST_FIRST (list) and we are thus unsure if the
memory location is dead.

I tried to bring that function inline, too, but it does not help, since alias
analysis won't figure out that passing the address to a function won't capture
it because we do not have nocapture discovery in early passes (it may be
valuable addition).

Anyway, it is easy to turn recursion into iteration here and probably makes
sense.

Bootstrapped/regtested x86_64-linux, OK?

Honza

        * sched-int.h (sd_iterator_cond): Manually tail recurse.
Index: sched-int.h
===================================================================
--- sched-int.h (revision 206233)
+++ sched-int.h (working copy)
@@ -1548,34 +1548,37 @@ sd_iterator_start (rtx insn, sd_list_typ
 static inline bool
 sd_iterator_cond (sd_iterator_def *it_ptr, dep_t *dep_ptr)
 {
-  dep_link_t link = *it_ptr->linkp;
-
-  if (link != NULL)
-    {
-      *dep_ptr = DEP_LINK_DEP (link);
-      return true;
-    }
-  else
+  while (true)
     {
-      sd_list_types_def types = it_ptr->types;
+      dep_link_t link = *it_ptr->linkp;
 
-      if (types != SD_LIST_NONE)
-       /* Switch to next list.  */
+      if (link != NULL)
+       {
+         *dep_ptr = DEP_LINK_DEP (link);
+         return true;
+       }
+      else
        {
-         deps_list_t list;
+         sd_list_types_def types = it_ptr->types;
 
-         sd_next_list (it_ptr->insn,
-                       &it_ptr->types, &list, &it_ptr->resolved_p);
+         if (types != SD_LIST_NONE)
+           /* Switch to next list.  */
+           {
+             deps_list_t list;
 
-         it_ptr->linkp = &DEPS_LIST_FIRST (list);
+             sd_next_list (it_ptr->insn,
+                           &it_ptr->types, &list, &it_ptr->resolved_p);
 
-         if (list)
-           return sd_iterator_cond (it_ptr, dep_ptr);
-       }
+             it_ptr->linkp = &DEPS_LIST_FIRST (list);
+
+             if (list)
+               continue;
+           }
 
-      *dep_ptr = NULL;
-      return false;
-    }
+         *dep_ptr = NULL;
+         return false;
+       }
+   }
 }
 
 /* Advance iterator.  */

Reply via email to