diff mbox

[gimple-classes,committed,09/44] auto-profile.c: Use gassign

Message ID 1415284340-14186-10-git-send-email-dmalcolm@redhat.com
State New
Headers show

Commit Message

David Malcolm Nov. 6, 2014, 2:31 p.m. UTC
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 mbox

Patch

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  <dmalcolm@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  <dmalcolm@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);