gcc/ChangeLog.gimple-classes:
        * auto-profile.c (afdo_propagate_circuit): Replace a check for
        GIMPLE_ASSIGN within the while loop with a dyn_cast, introducing
        a local "def_assign", using it in place of "stmt" for typesafety.
        This involves replacing the series of while conditions in the head
        of the while into a list of conditionals within its body that
        break out of the loop, thus requiring the conditions to be
        negated.
---
 gcc/ChangeLog.gimple-classes | 10 ++++++++++
 gcc/auto-profile.c           | 15 +++++++++++----
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index 5902705..e8d2d6e 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,3 +1,13 @@
+2014-11-03  David Malcolm  <dmalc...@redhat.com>
+
+       * auto-profile.c (afdo_propagate_circuit): Replace a check for
+       GIMPLE_ASSIGN within the while loop with a dyn_cast, introducing
+       a local "def_assign", using it in place of "stmt" for typesafety.
+       This involves replacing the series of while conditions in the head
+       of the while into a list of conditionals within its body that
+       break out of the loop, thus requiring the conditions to be
+       negated.
+
 2014-10-31  David Malcolm  <dmalc...@redhat.com>
 
        * tree-ssa-forwprop.c (get_prop_source_stmt): Strengthen return
diff --git a/gcc/auto-profile.c b/gcc/auto-profile.c
index ba4e567..320b2f6 100644
--- a/gcc/auto-profile.c
+++ b/gcc/auto-profile.c
@@ -1262,10 +1262,17 @@ afdo_propagate_circuit (const bb_set &annotated_bb, 
edge_set *annotated_edge)
     if (!is_bb_annotated (bb, annotated_bb))
       continue;
     def_stmt = SSA_NAME_DEF_STMT (cmp_lhs);
-    while (def_stmt && gimple_code (def_stmt) == GIMPLE_ASSIGN
-           && gimple_assign_single_p (def_stmt)
-           && TREE_CODE (gimple_assign_rhs1 (def_stmt)) == SSA_NAME)
-      def_stmt = SSA_NAME_DEF_STMT (gimple_assign_rhs1 (def_stmt));
+    while (def_stmt)
+      {
+       gassign *def_assign = dyn_cast <gassign *> (def_stmt);
+       if (!def_assign)
+         break;
+       if (!gimple_assign_single_p (def_assign))
+         break;
+       if (TREE_CODE (gimple_assign_rhs1 (def_assign)) != SSA_NAME)
+         break;
+       def_stmt = SSA_NAME_DEF_STMT (gimple_assign_rhs1 (def_assign));
+      }
     if (!def_stmt)
       continue;
     gphi *phi_stmt = dyn_cast <gphi *> (def_stmt);
-- 
1.7.11.7

Reply via email to