This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gimple-classes, committed 13/44] rewrite_to_defined_overflow takes a gassign *


gcc/ChangeLog.gimple-classes:
	* gimple-fold.h (rewrite_to_defined_overflow): Strengthen from
	gimple to gassign *.
	* gimple-fold.c (rewrite_to_defined_overflow): Likewise.
	* tree-scalar-evolution.c (scev_const_prop): Replace
	is_gimple_assign with a dyn_cast, introducing local "assign_stmt"
	and using it in place of "stmt" for typesafety.
	* tree-ssa-loop-im.c
	(move_computations_dom_walker::before_dom_children): Likewise.
---
 gcc/ChangeLog.gimple-classes | 11 +++++++++++
 gcc/gimple-fold.c            |  2 +-
 gcc/gimple-fold.h            |  2 +-
 gcc/tree-scalar-evolution.c  |  7 ++++---
 gcc/tree-ssa-loop-im.c       | 12 +++++++-----
 5 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index be9aa76..c766c36 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,5 +1,16 @@
 2014-11-03  David Malcolm  <dmalcolm@redhat.com>
 
+	* gimple-fold.h (rewrite_to_defined_overflow): Strengthen from
+	gimple to gassign *.
+	* gimple-fold.c (rewrite_to_defined_overflow): Likewise.
+	* tree-scalar-evolution.c (scev_const_prop): Replace
+	is_gimple_assign with a dyn_cast, introducing local "assign_stmt"
+	and using it in place of "stmt" for typesafety.
+	* tree-ssa-loop-im.c
+	(move_computations_dom_walker::before_dom_children): Likewise.
+
+2014-11-03  David Malcolm  <dmalcolm@redhat.com>
+
 	* gimple-fold.c (fold_gimple_assign): Strengthen local "stmt" from
 	gimple to gassign * via a checked cast.
 	(gsi_replace_with_seq_vops): Add a checked cast within region
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index 3b85686..708be05 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -5503,7 +5503,7 @@ arith_code_with_undefined_signed_overflow (tree_code code)
    a modified form of STMT itself.  */
 
 gimple_seq
-rewrite_to_defined_overflow (gimple stmt)
+rewrite_to_defined_overflow (gassign *stmt)
 {
   if (dump_file && (dump_flags & TDF_DETAILS))
     {
diff --git a/gcc/gimple-fold.h b/gcc/gimple-fold.h
index 39c53ff..51d0225 100644
--- a/gcc/gimple-fold.h
+++ b/gcc/gimple-fold.h
@@ -45,7 +45,7 @@ extern tree gimple_get_virt_method_for_vtable (HOST_WIDE_INT, tree,
 extern bool gimple_val_nonnegative_real_p (tree);
 extern tree gimple_fold_indirect_ref (tree);
 extern bool arith_code_with_undefined_signed_overflow (tree_code);
-extern gimple_seq rewrite_to_defined_overflow (gimple);
+extern gimple_seq rewrite_to_defined_overflow (gassign *);
 
 /* gimple_build, functionally matching fold_buildN, outputs stmts
    int the provided sequence, matching and simplifying them on-the-fly.
diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c
index 38b0767..5c8767c 100644
--- a/gcc/tree-scalar-evolution.c
+++ b/gcc/tree-scalar-evolution.c
@@ -3518,13 +3518,14 @@ scev_const_prop (void)
 		{
 		  gimple stmt = gsi_stmt (gsi2);
 		  gimple_stmt_iterator gsi3 = gsi2;
+		  gassign *assign_stmt;
 		  gsi_next (&gsi2);
 		  gsi_remove (&gsi3, false);
-		  if (is_gimple_assign (stmt)
+		  if ((assign_stmt = dyn_cast <gassign *> (stmt))
 		      && arith_code_with_undefined_signed_overflow
-					(gimple_assign_rhs_code (stmt)))
+					(gimple_assign_rhs_code (assign_stmt)))
 		    gsi_insert_seq_before (&gsi,
-					   rewrite_to_defined_overflow (stmt),
+					   rewrite_to_defined_overflow (assign_stmt),
 					   GSI_SAME_STMT);
 		  else
 		    gsi_insert_before (&gsi, stmt, GSI_SAME_STMT);
diff --git a/gcc/tree-ssa-loop-im.c b/gcc/tree-ssa-loop-im.c
index cb0ce4b..9fa556e 100644
--- a/gcc/tree-ssa-loop-im.c
+++ b/gcc/tree-ssa-loop-im.c
@@ -1244,6 +1244,7 @@ move_computations_dom_walker::before_dom_children (basic_block bb)
       edge e;
 
       gimple stmt = gsi_stmt (bsi);
+      gassign *assign_stmt;
 
       lim_data = get_lim_data (stmt);
       if (lim_data == NULL)
@@ -1298,15 +1299,16 @@ move_computations_dom_walker::before_dom_children (basic_block bb)
          when the target loop header is executed and the stmt may
 	 invoke undefined integer or pointer overflow rewrite it to
 	 unsigned arithmetic.  */
-      if (is_gimple_assign (stmt)
-	  && INTEGRAL_TYPE_P (TREE_TYPE (gimple_assign_lhs (stmt)))
-	  && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (gimple_assign_lhs (stmt)))
+      if ((assign_stmt = dyn_cast <gassign *> (stmt))
+	  && INTEGRAL_TYPE_P (TREE_TYPE (gimple_assign_lhs (assign_stmt)))
+	  && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (
+				        gimple_assign_lhs (assign_stmt)))
 	  && arith_code_with_undefined_signed_overflow
-	       (gimple_assign_rhs_code (stmt))
+	       (gimple_assign_rhs_code (assign_stmt))
 	  && (!ALWAYS_EXECUTED_IN (bb)
 	      || !(ALWAYS_EXECUTED_IN (bb) == level
 		   || flow_loop_nested_p (ALWAYS_EXECUTED_IN (bb), level))))
-	gsi_insert_seq_on_edge (e, rewrite_to_defined_overflow (stmt));
+	gsi_insert_seq_on_edge (e, rewrite_to_defined_overflow (assign_stmt));
       else
 	gsi_insert_on_edge (e, stmt);
     }
-- 
1.7.11.7


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]