gcc/ChangeLog.gimple-classes:
        * tree-ssa-forwprop.c (simplify_builtin_call): Strengthen local
        "stmt2" from gimple to gcall * via a checked cast.  Replace
        is_gimple_call with a dyn_cast, introducing local "call_stmt1",
        and using the latter in place of "stmt1" for typesafety.
        Introduce another local "call_stmt1" for typesafety via a
        checked cast within the if (callee1) block, which is only
        reachable if we have a GIMPLE_CALL.
        * tree-ssa-reassoc.c (attempt_builtin_powi): Strengthen local
        "pow_stmt" from gimple to gcall *.
        * tree-ssa-strlen.c (get_string_length): Likewise for local
        "stmt", via a checked cast.
---
 gcc/ChangeLog.gimple-classes | 14 ++++++++++++++
 gcc/tree-ssa-forwprop.c      | 25 ++++++++++++++-----------
 gcc/tree-ssa-reassoc.c       |  3 ++-
 gcc/tree-ssa-strlen.c        |  2 +-
 4 files changed, 31 insertions(+), 13 deletions(-)

diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index 33bd5bf..5c3cbd5 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,5 +1,19 @@
 2014-10-31  David Malcolm  <dmalc...@redhat.com>
 
+       * tree-ssa-forwprop.c (simplify_builtin_call): Strengthen local
+       "stmt2" from gimple to gcall * via a checked cast.  Replace
+       is_gimple_call with a dyn_cast, introducing local "call_stmt1",
+       and using the latter in place of "stmt1" for typesafety.
+       Introduce another local "call_stmt1" for typesafety via a
+       checked cast within the if (callee1) block, which is only
+       reachable if we have a GIMPLE_CALL.
+       * tree-ssa-reassoc.c (attempt_builtin_powi): Strengthen local
+       "pow_stmt" from gimple to gcall *.
+       * tree-ssa-strlen.c (get_string_length): Likewise for local
+       "stmt", via a checked cast.
+
+2014-10-31  David Malcolm  <dmalc...@redhat.com>
+
        * gimple.c (gimple_set_lhs): Add checked casts to gassign * and
        gcall * as appropriate.
        * tree-cfg.c (execute_fixup_cfg): Introduce local "call_stmt"
diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c
index 1f4c9de..3a03b9f 100644
--- a/gcc/tree-ssa-forwprop.c
+++ b/gcc/tree-ssa-forwprop.c
@@ -1515,7 +1515,8 @@ constant_pointer_difference (tree p1, tree p2)
 static bool
 simplify_builtin_call (gimple_stmt_iterator *gsi_p, tree callee2)
 {
-  gimple stmt1, stmt2 = gsi_stmt (*gsi_p);
+  gimple stmt1;
+  gcall *stmt2 = as_a <gcall *> (gsi_stmt (*gsi_p));
   tree vuse = gimple_vuse (stmt2);
   if (vuse == NULL)
     return false;
@@ -1546,23 +1547,23 @@ simplify_builtin_call (gimple_stmt_iterator *gsi_p, 
tree callee2)
          if (!tree_fits_shwi_p (val2)
              || !tree_fits_uhwi_p (len2))
            break;
-         if (is_gimple_call (stmt1))
+         if (gcall *call_stmt1 = dyn_cast <gcall *> (stmt1))
            {
              /* If first stmt is a call, it needs to be memcpy
                 or mempcpy, with string literal as second argument and
                 constant length.  */
-             callee1 = gimple_call_fndecl (stmt1);
+             callee1 = gimple_call_fndecl (call_stmt1);
              if (callee1 == NULL_TREE
                  || DECL_BUILT_IN_CLASS (callee1) != BUILT_IN_NORMAL
-                 || gimple_call_num_args (stmt1) != 3)
+                 || gimple_call_num_args (call_stmt1) != 3)
                break;
              if (DECL_FUNCTION_CODE (callee1) != BUILT_IN_MEMCPY
                  && DECL_FUNCTION_CODE (callee1) != BUILT_IN_MEMPCPY)
                break;
-             ptr1 = gimple_call_arg (stmt1, 0);
-             src1 = gimple_call_arg (stmt1, 1);
-             len1 = gimple_call_arg (stmt1, 2);
-             lhs1 = gimple_call_lhs (stmt1);
+             ptr1 = gimple_call_arg (call_stmt1, 0);
+             src1 = gimple_call_arg (call_stmt1, 1);
+             len1 = gimple_call_arg (call_stmt1, 2);
+             lhs1 = gimple_call_lhs (call_stmt1);
              if (!tree_fits_uhwi_p (len1))
                break;
              str1 = string_constant (src1, &off1);
@@ -1668,12 +1669,14 @@ simplify_builtin_call (gimple_stmt_iterator *gsi_p, 
tree callee2)
          new_str_cst = build_string_literal (src_len, src_buf);
          if (callee1)
            {
+             gcall *call_stmt1 = as_a <gcall *> (stmt1);
+
              /* If STMT1 is a mem{,p}cpy call, adjust it and remove
                 memset call.  */
              if (lhs1 && DECL_FUNCTION_CODE (callee1) == BUILT_IN_MEMPCPY)
-               gimple_call_set_lhs (stmt1, NULL_TREE);
-             gimple_call_set_arg (stmt1, 1, new_str_cst);
-             gimple_call_set_arg (stmt1, 2,
+               gimple_call_set_lhs (call_stmt1, NULL_TREE);
+             gimple_call_set_arg (call_stmt1, 1, new_str_cst);
+             gimple_call_set_arg (call_stmt1, 2,
                                   build_int_cst (TREE_TYPE (len1), src_len));
              update_stmt (stmt1);
              unlink_stmt_vdef (stmt2);
diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c
index a1714fd..c1a54d3 100644
--- a/gcc/tree-ssa-reassoc.c
+++ b/gcc/tree-ssa-reassoc.c
@@ -4372,7 +4372,8 @@ attempt_builtin_powi (gimple stmt, vec<operand_entry_t> 
*ops)
   tree type = TREE_TYPE (gimple_get_lhs (stmt));
   tree powi_fndecl = mathfn_built_in (type, BUILT_IN_POWI);
   gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
-  gimple mul_stmt, pow_stmt;
+  gimple mul_stmt;
+  gcall *pow_stmt;
 
   /* Nothing to do if BUILT_IN_POWI doesn't exist for this type and
      target.  */
diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c
index f9cfed5..43f866f 100644
--- a/gcc/tree-ssa-strlen.c
+++ b/gcc/tree-ssa-strlen.c
@@ -416,7 +416,7 @@ get_string_length (strinfo si)
 
   if (si->stmt)
     {
-      gimple stmt = si->stmt;
+      gcall *stmt = as_a <gcall *> (si->stmt);
       gcall *call_stmt;
       gassign *assign_stmt;
       tree callee, lhs, fn, tem;
-- 
1.7.11.7

Reply via email to