This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH 05/16] Introduce gimple_assign and use it in various places
- From: David Malcolm <dmalcolm at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: David Malcolm <dmalcolm at redhat dot com>
- Date: Fri, 13 Dec 2013 10:58:15 -0500
- Subject: [PATCH 05/16] Introduce gimple_assign and use it in various places
- Authentication-results: sourceware.org; auth=none
- References: <1386950306-11944-1-git-send-email-dmalcolm at redhat dot com>
gcc/
* coretypes.h (gimple_assign): New typedef.
(const_gimple_assign): New typedef.
* gimple.h (struct gimple_statement_assign): New subclass of
gimple_statement_with_memory_ops, adding the invariant that
stmt->code == GIMPLE_ASSIGN.
(gimple_statement_base::as_a_gimple_assign): New.
(gimple_statement_base::dyn_cast_gimple_assign): New.
(is_a_helper <gimple_statement_assign>::test): New.
* gdbhooks.py (build_pretty_printer): Add gimple_assign and its
variants, using the gimple printer.
* gimple-builder.c (build_assign): Return a gimple_assign rather
than just a gimple from each of the overloaded variants.
(build_type_cast): Likewise.
* gimple-builder.h (build_assign): Likewise.
(build_type_cast): Likewise.
* gimple.c (gimple_build_assign_stat): Likewise.
(gimple_build_assign_with_ops): Likewise.
* gimple.h (gimple_build_assign_stat): Likewise.
(gimple_build_assign_with_ops): Likewise.
* asan.c (get_mem_ref_of_assignment): Require a const_gimple_assign
rather than just a "const gimple" (the latter is not a
"const_gimple").
* gimple-pretty-print.c (dump_unary_rhs): Require a gimple_assign
rather than just a gimple.
(dump_binary_rhs): Likewise.
(dump_ternary_rhs): Likewise.
* tree-cfg.c (verify_gimple_assign_unary): Likewise.
(verify_gimple_assign_binary): Likewise.
(verify_gimple_assign_ternary): Likewise.
(verify_gimple_assign_single): Likewise.
(verify_gimple_assign): Likewise.
* tree-ssa-sccvn.c (simplify_unary_expression): Likewise.
(try_to_simplify): Likewise.
* tree-tailcall.c (process_assignment): Likewise.
* tree-vect-generic.c (expand_vector_operation): Likewise.
* tree-vrp.c (extract_range_from_cond_expr): Likewise.
(extract_range_from_assignment): Likewise.
* asan.c (has_stmt_been_instrumented_p): Add checked cast to
gimple_assign in regions where a stmt is known to have code
GIMPLE_ASSIGN.
* gimple-pretty-print.c (pp_gimple_stmt_1): Likewise.
* tree-cfg.c (verify_gimple_stmt): Likewise.
* tree-ssa-sccvn.c (visit_use): Likewise.
* tree-tailcall.c (find_tail_calls): Likewise.
* tree-vrp.c (vrp_visit_assignment_or_call): Likewise.
* tree-vrp.c (simplify_stmt_for_jump_threading): Replace a check
against GIMPLE_ASSIGN with a dyn_cast_gimple_assign, introducing
a gimple_assign local.
* tree-vect-generic.c (expand_vector_condition): Convert local to a
gimple_assign, adding a checked cast when extracting from gsi, since
this is only called when underlying stmt has code GIMPLE_ASSIGN.
(optimize_vector_constructor): Likewise.
(lower_vec_perm): Likewise.
(expand_vector_operations_1): Convert local to a gimple_assign,
introducing a dyn_cast.
---
gcc/asan.c | 5 +++--
gcc/coretypes.h | 4 ++++
gcc/gdbhooks.py | 2 ++
gcc/gimple-builder.c | 16 ++++++++--------
gcc/gimple-builder.h | 16 ++++++++--------
gcc/gimple-pretty-print.c | 10 +++++-----
gcc/gimple.c | 10 +++++-----
gcc/gimple.h | 41 ++++++++++++++++++++++++++++++++++++-----
gcc/tree-cfg.c | 12 ++++++------
gcc/tree-ssa-sccvn.c | 6 +++---
gcc/tree-tailcall.c | 5 +++--
gcc/tree-vect-generic.c | 13 +++++++------
gcc/tree-vrp.c | 12 ++++++------
13 files changed, 96 insertions(+), 56 deletions(-)
diff --git a/gcc/asan.c b/gcc/asan.c
index 74140d6..1c95da1 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -433,7 +433,7 @@ has_mem_ref_been_instrumented (const asan_mem_ref *ref, tree len)
otherwise. */
static bool
-get_mem_ref_of_assignment (const gimple assignment,
+get_mem_ref_of_assignment (const_gimple_assign assignment,
asan_mem_ref *ref,
bool *ref_is_store)
{
@@ -801,7 +801,8 @@ has_stmt_been_instrumented_p (gimple stmt)
asan_mem_ref r;
asan_mem_ref_init (&r, NULL, 1);
- if (get_mem_ref_of_assignment (stmt, &r, &r_is_store))
+ if (get_mem_ref_of_assignment (stmt->as_a_gimple_assign (), &r,
+ &r_is_store))
return has_mem_ref_been_instrumented (&r);
}
else if (gimple_call_builtin_p (stmt, BUILT_IN_NORMAL))
diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index bb7c0bd..831a8a7 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -78,6 +78,10 @@ struct gimple_statement_switch;
typedef struct gimple_statement_switch *gimple_switch;
typedef const struct gimple_statement_switch *const_gimple_switch;
+struct gimple_statement_assign;
+typedef struct gimple_statement_assign *gimple_assign;
+typedef const struct gimple_statement_assign *const_gimple_assign;
+
struct gimple_statement_bind;
typedef struct gimple_statement_bind *gimple_bind;
typedef const struct gimple_statement_bind *const_gimple_bind;
diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py
index 5673826..933a7ee 100644
--- a/gcc/gdbhooks.py
+++ b/gcc/gdbhooks.py
@@ -461,6 +461,8 @@ def build_pretty_printer():
'gimple_statement_cond *',
'gimple_switch', 'const_gimple_switch',
'gimple_statement_switch *',
+ 'gimple_assign', 'const_gimple_assign',
+ 'gimple_statement_assign *',
'gimple_bind', 'const_gimple_bind',
'gimple_statement_bind *'],
diff --git a/gcc/gimple-builder.c b/gcc/gimple-builder.c
index a670c7e..113f04f 100644
--- a/gcc/gimple-builder.c
+++ b/gcc/gimple-builder.c
@@ -51,7 +51,7 @@ get_expr_type (enum tree_code code, tree op)
the expression code for the RHS. OP1 is the first operand and VAL
is an integer value to be used as the second operand. */
-gimple
+gimple_assign
build_assign (enum tree_code code, tree op1, int val, tree lhs)
{
tree op2 = build_int_cst (TREE_TYPE (op1), val);
@@ -60,7 +60,7 @@ build_assign (enum tree_code code, tree op1, int val, tree lhs)
return gimple_build_assign_with_ops (code, lhs, op1, op2);
}
-gimple
+gimple_assign
build_assign (enum tree_code code, gimple g, int val, tree lhs )
{
return build_assign (code, gimple_assign_lhs (g), val, lhs);
@@ -75,7 +75,7 @@ build_assign (enum tree_code code, gimple g, int val, tree lhs )
in normal form depending on the type of builder invoking this
function. */
-gimple
+gimple_assign
build_assign (enum tree_code code, tree op1, tree op2, tree lhs)
{
if (lhs == NULL_TREE)
@@ -83,19 +83,19 @@ build_assign (enum tree_code code, tree op1, tree op2, tree lhs)
return gimple_build_assign_with_ops (code, lhs, op1, op2);
}
-gimple
+gimple_assign
build_assign (enum tree_code code, gimple op1, tree op2, tree lhs)
{
return build_assign (code, gimple_assign_lhs (op1), op2, lhs);
}
-gimple
+gimple_assign
build_assign (enum tree_code code, tree op1, gimple op2, tree lhs)
{
return build_assign (code, op1, gimple_assign_lhs (op2), lhs);
}
-gimple
+gimple_assign
build_assign (enum tree_code code, gimple op1, gimple op2, tree lhs)
{
return build_assign (code, gimple_assign_lhs (op1), gimple_assign_lhs (op2),
@@ -106,7 +106,7 @@ build_assign (enum tree_code code, gimple op1, gimple op2, tree lhs)
/* Create and return a type cast assignment. This creates a NOP_EXPR
that converts OP to TO_TYPE. */
-gimple
+gimple_assign
build_type_cast (tree to_type, tree op, tree lhs)
{
if (lhs == NULL_TREE)
@@ -114,7 +114,7 @@ build_type_cast (tree to_type, tree op, tree lhs)
return gimple_build_assign_with_ops (NOP_EXPR, lhs, op, NULL_TREE);
}
-gimple
+gimple_assign
build_type_cast (tree to_type, gimple op, tree lhs)
{
return build_type_cast (to_type, gimple_assign_lhs (op), lhs);
diff --git a/gcc/gimple-builder.h b/gcc/gimple-builder.h
index 532c04e..331ce30 100644
--- a/gcc/gimple-builder.h
+++ b/gcc/gimple-builder.h
@@ -22,13 +22,13 @@ along with GCC; see the file COPYING3. If not see
#define GCC_GIMPLE_BUILDER_H
tree create_gimple_tmp (tree, tree lhs = NULL_TREE);
-gimple build_assign (enum tree_code, tree, int, tree lhs = NULL_TREE);
-gimple build_assign (enum tree_code, gimple, int, tree lhs = NULL_TREE);
-gimple build_assign (enum tree_code, tree, tree, tree lhs = NULL_TREE);
-gimple build_assign (enum tree_code, gimple, tree, tree lhs = NULL_TREE);
-gimple build_assign (enum tree_code, tree, gimple, tree lhs = NULL_TREE);
-gimple build_assign (enum tree_code, gimple, gimple, tree lhs = NULL_TREE);
-gimple build_type_cast (tree, tree, tree lhs = NULL_TREE);
-gimple build_type_cast (tree, gimple, tree lhs = NULL_TREE);
+gimple_assign build_assign (enum tree_code, tree, int, tree lhs = NULL_TREE);
+gimple_assign build_assign (enum tree_code, gimple, int, tree lhs = NULL_TREE);
+gimple_assign build_assign (enum tree_code, tree, tree, tree lhs = NULL_TREE);
+gimple_assign build_assign (enum tree_code, gimple, tree, tree lhs = NULL_TREE);
+gimple_assign build_assign (enum tree_code, tree, gimple, tree lhs = NULL_TREE);
+gimple_assign build_assign (enum tree_code, gimple, gimple, tree lhs = NULL_TREE);
+gimple_assign build_type_cast (tree, tree, tree lhs = NULL_TREE);
+gimple_assign build_type_cast (tree, gimple, tree lhs = NULL_TREE);
#endif /* GCC_GIMPLE_BUILDER_H */
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index 5ee61dd..9f55bcf 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -261,7 +261,7 @@ dump_gimple_fmt (pretty_printer *buffer, int spc, int flags,
assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
static void
-dump_unary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_unary_rhs (pretty_printer *buffer, gimple_assign gs, int spc, int flags)
{
enum tree_code rhs_code = gimple_assign_rhs_code (gs);
tree lhs = gimple_assign_lhs (gs);
@@ -345,7 +345,7 @@ dump_unary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
static void
-dump_binary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_binary_rhs (pretty_printer *buffer, gimple_assign gs, int spc, int flags)
{
const char *p;
enum tree_code code = gimple_assign_rhs_code (gs);
@@ -401,7 +401,7 @@ dump_binary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
static void
-dump_ternary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_ternary_rhs (pretty_printer *buffer, gimple_assign gs, int spc, int flags)
{
const char *p;
enum tree_code code = gimple_assign_rhs_code (gs);
@@ -486,7 +486,7 @@ dump_ternary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
pp_gimple_stmt_1. */
static void
-dump_gimple_assign (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_gimple_assign (pretty_printer *buffer, gimple_assign gs, int spc, int flags)
{
if (flags & TDF_RAW)
{
@@ -2094,7 +2094,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
break;
case GIMPLE_ASSIGN:
- dump_gimple_assign (buffer, gs, spc, flags);
+ dump_gimple_assign (buffer, gs->as_a_gimple_assign (), spc, flags);
break;
case GIMPLE_BIND:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 099e4dd4..e94dd33 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -377,7 +377,7 @@ gimple_build_call_from_tree (tree t)
LHS of the assignment.
RHS of the assignment which can be unary or binary. */
-gimple
+gimple_assign
gimple_build_assign_stat (tree lhs, tree rhs MEM_STAT_DECL)
{
enum tree_code subcode;
@@ -393,19 +393,19 @@ gimple_build_assign_stat (tree lhs, tree rhs MEM_STAT_DECL)
OP1 and OP2. If OP2 is NULL then SUBCODE must be of class
GIMPLE_UNARY_RHS or GIMPLE_SINGLE_RHS. */
-gimple
+gimple_assign
gimple_build_assign_with_ops (enum tree_code subcode, tree lhs, tree op1,
tree op2, tree op3 MEM_STAT_DECL)
{
unsigned num_ops;
- gimple p;
+ gimple_assign p;
/* Need 1 operand for LHS and 1 or 2 for the RHS (depending on the
code). */
num_ops = get_gimple_rhs_num_ops (subcode) + 1;
p = gimple_build_with_ops_stat (GIMPLE_ASSIGN, (unsigned)subcode, num_ops
- PASS_MEM_STAT);
+ PASS_MEM_STAT)->as_a_gimple_assign ();
gimple_assign_set_lhs (p, lhs);
gimple_assign_set_rhs1 (p, op1);
if (op2)
@@ -423,7 +423,7 @@ gimple_build_assign_with_ops (enum tree_code subcode, tree lhs, tree op1,
return p;
}
-gimple
+gimple_assign
gimple_build_assign_with_ops (enum tree_code subcode, tree lhs, tree op1,
tree op2 MEM_STAT_DECL)
{
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 981c65d..af01873 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -223,6 +223,12 @@ public:
return as_a <gimple_statement_switch> (this);
}
+ inline gimple_assign
+ as_a_gimple_assign ()
+ {
+ return as_a <gimple_statement_assign> (this);
+ }
+
inline gimple_bind
as_a_gimple_bind ()
{
@@ -249,6 +255,12 @@ public:
return dyn_cast <gimple_statement_switch> (this);
}
+ inline gimple_assign
+ dyn_cast_gimple_assign ()
+ {
+ return dyn_cast <gimple_statement_assign> (this);
+ }
+
inline gimple_bind
dyn_cast_gimple_bind ()
{
@@ -840,6 +852,16 @@ struct GTY((tag("GSS_WITH_OPS")))
/* no additional fields; this uses the layout for GSS_WITH_OPS. */
};
+/* A statement with the invariant that
+ stmt->code == GIMPLE_ASSIGN
+ i.e. an assignment statement. */
+
+struct GTY((tag("GSS_WITH_MEM_OPS")))
+ gimple_statement_assign : public gimple_statement_with_memory_ops
+{
+ /* no additional fields; this uses the layout for GSS_WITH_MEM_OPS. */
+};
+
template <>
template <>
inline bool
@@ -851,6 +873,14 @@ is_a_helper <gimple_statement_asm>::test (gimple gs)
template <>
template <>
inline bool
+is_a_helper <gimple_statement_assign>::test (gimple gs)
+{
+ return gs->code == GIMPLE_ASSIGN;
+}
+
+template <>
+template <>
+inline bool
is_a_helper <gimple_statement_bind>::test (gimple gs)
{
return gs->code == GIMPLE_BIND;
@@ -1261,12 +1291,13 @@ gimple gimple_build_call_valist (tree, unsigned, va_list);
gimple gimple_build_call_internal (enum internal_fn, unsigned, ...);
gimple gimple_build_call_internal_vec (enum internal_fn, vec<tree> );
gimple gimple_build_call_from_tree (tree);
-gimple gimple_build_assign_stat (tree, tree MEM_STAT_DECL);
+gimple_assign gimple_build_assign_stat (tree, tree MEM_STAT_DECL);
#define gimple_build_assign(l,r) gimple_build_assign_stat (l, r MEM_STAT_INFO)
-gimple gimple_build_assign_with_ops (enum tree_code, tree,
- tree, tree, tree CXX_MEM_STAT_INFO);
-gimple gimple_build_assign_with_ops (enum tree_code, tree,
- tree, tree CXX_MEM_STAT_INFO);
+gimple_assign gimple_build_assign_with_ops (enum tree_code, tree,
+ tree, tree,
+ tree CXX_MEM_STAT_INFO);
+gimple_assign gimple_build_assign_with_ops (enum tree_code, tree,
+ tree, tree CXX_MEM_STAT_INFO);
gimple_cond gimple_build_cond (enum tree_code, tree, tree, tree, tree);
gimple_cond gimple_build_cond_from_tree (tree, tree, tree);
void gimple_cond_set_condition_from_tree (gimple_cond, tree);
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 52ee66e..9671407 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -3298,7 +3298,7 @@ verify_gimple_comparison (tree type, tree op0, tree op1)
Returns true if anything is wrong. */
static bool
-verify_gimple_assign_unary (gimple stmt)
+verify_gimple_assign_unary (gimple_assign stmt)
{
enum tree_code rhs_code = gimple_assign_rhs_code (stmt);
tree lhs = gimple_assign_lhs (stmt);
@@ -3452,7 +3452,7 @@ verify_gimple_assign_unary (gimple stmt)
Returns true if anything is wrong. */
static bool
-verify_gimple_assign_binary (gimple stmt)
+verify_gimple_assign_binary (gimple_assign stmt)
{
enum tree_code rhs_code = gimple_assign_rhs_code (stmt);
tree lhs = gimple_assign_lhs (stmt);
@@ -3726,7 +3726,7 @@ verify_gimple_assign_binary (gimple stmt)
Returns true if anything is wrong. */
static bool
-verify_gimple_assign_ternary (gimple stmt)
+verify_gimple_assign_ternary (gimple_assign stmt)
{
enum tree_code rhs_code = gimple_assign_rhs_code (stmt);
tree lhs = gimple_assign_lhs (stmt);
@@ -3869,7 +3869,7 @@ verify_gimple_assign_ternary (gimple stmt)
Returns true if anything is wrong. */
static bool
-verify_gimple_assign_single (gimple stmt)
+verify_gimple_assign_single (gimple_assign stmt)
{
enum tree_code rhs_code = gimple_assign_rhs_code (stmt);
tree lhs = gimple_assign_lhs (stmt);
@@ -4069,7 +4069,7 @@ verify_gimple_assign_single (gimple stmt)
is a problem, otherwise false. */
static bool
-verify_gimple_assign (gimple stmt)
+verify_gimple_assign (gimple_assign stmt)
{
switch (gimple_assign_rhs_class (stmt))
{
@@ -4307,7 +4307,7 @@ verify_gimple_stmt (gimple stmt)
switch (gimple_code (stmt))
{
case GIMPLE_ASSIGN:
- return verify_gimple_assign (stmt);
+ return verify_gimple_assign (stmt->as_a_gimple_assign ());
case GIMPLE_LABEL:
return verify_gimple_label (stmt);
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index e98652c..5e1a023 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -3271,7 +3271,7 @@ simplify_binary_expression (gimple stmt)
simplified. */
static tree
-simplify_unary_expression (gimple stmt)
+simplify_unary_expression (gimple_assign stmt)
{
tree result = NULL_TREE;
tree orig_op0, op0 = gimple_assign_rhs1 (stmt);
@@ -3334,7 +3334,7 @@ simplify_unary_expression (gimple stmt)
/* Try to simplify RHS using equivalences and constant folding. */
static tree
-try_to_simplify (gimple stmt)
+try_to_simplify (gimple_assign stmt)
{
enum tree_code code = gimple_assign_rhs_code (stmt);
tree tem;
@@ -3422,7 +3422,7 @@ visit_use (tree use)
changed = visit_copy (lhs, rhs1);
goto done;
}
- simplified = try_to_simplify (stmt);
+ simplified = try_to_simplify (stmt->as_a_gimple_assign ());
if (simplified)
{
if (dump_file && (dump_flags & TDF_DETAILS))
diff --git a/gcc/tree-tailcall.c b/gcc/tree-tailcall.c
index 37603b2..8c38678 100644
--- a/gcc/tree-tailcall.c
+++ b/gcc/tree-tailcall.c
@@ -267,7 +267,7 @@ independent_of_stmt_p (tree expr, gimple at, gimple_stmt_iterator gsi)
additive factor for the real return value. */
static bool
-process_assignment (gimple stmt, gimple_stmt_iterator call, tree *m,
+process_assignment (gimple_assign stmt, gimple_stmt_iterator call, tree *m,
tree *a, tree *ass_var)
{
tree op0, op1 = NULL_TREE, non_ass_var = NULL_TREE;
@@ -549,7 +549,8 @@ find_tail_calls (basic_block bb, struct tailcall **ret)
return;
/* This is a gimple assign. */
- if (! process_assignment (stmt, gsi, &tmp_m, &tmp_a, &ass_var))
+ if (! process_assignment (stmt->as_a_gimple_assign (), gsi, &tmp_m,
+ &tmp_a, &ass_var))
return;
if (tmp_a)
diff --git a/gcc/tree-vect-generic.c b/gcc/tree-vect-generic.c
index d55485d..3549cec 100644
--- a/gcc/tree-vect-generic.c
+++ b/gcc/tree-vect-generic.c
@@ -837,7 +837,7 @@ expand_vector_divmod (gimple_stmt_iterator *gsi, tree type, tree op0,
static void
expand_vector_condition (gimple_stmt_iterator *gsi)
{
- gimple stmt = gsi_stmt (*gsi);
+ gimple_assign stmt = gsi_stmt (*gsi)->as_a_gimple_assign ();
tree type = gimple_expr_type (stmt);
tree a = gimple_assign_rhs1 (stmt);
tree a1 = a;
@@ -900,7 +900,7 @@ expand_vector_condition (gimple_stmt_iterator *gsi)
static tree
expand_vector_operation (gimple_stmt_iterator *gsi, tree type, tree compute_type,
- gimple assign, enum tree_code code)
+ gimple_assign assign, enum tree_code code)
{
enum machine_mode compute_mode = TYPE_MODE (compute_type);
@@ -1005,7 +1005,7 @@ expand_vector_operation (gimple_stmt_iterator *gsi, tree type, tree compute_type
static void
optimize_vector_constructor (gimple_stmt_iterator *gsi)
{
- gimple stmt = gsi_stmt (*gsi);
+ gimple_assign stmt = gsi_stmt (*gsi)->as_a_gimple_assign ();
tree lhs = gimple_assign_lhs (stmt);
tree rhs = gimple_assign_rhs1 (stmt);
tree type = TREE_TYPE (rhs);
@@ -1220,7 +1220,7 @@ vector_element (gimple_stmt_iterator *gsi, tree vect, tree idx, tree *ptmpvec)
static void
lower_vec_perm (gimple_stmt_iterator *gsi)
{
- gimple stmt = gsi_stmt (*gsi);
+ gimple_assign stmt = gsi_stmt (*gsi)->as_a_gimple_assign ();
tree mask = gimple_assign_rhs3 (stmt);
tree vec0 = gimple_assign_rhs1 (stmt);
tree vec1 = gimple_assign_rhs2 (stmt);
@@ -1340,7 +1340,6 @@ lower_vec_perm (gimple_stmt_iterator *gsi)
static void
expand_vector_operations_1 (gimple_stmt_iterator *gsi)
{
- gimple stmt = gsi_stmt (*gsi);
tree lhs, rhs1, rhs2 = NULL, type, compute_type;
enum tree_code code;
enum machine_mode compute_mode;
@@ -1348,7 +1347,9 @@ expand_vector_operations_1 (gimple_stmt_iterator *gsi)
enum gimple_rhs_class rhs_class;
tree new_rhs;
- if (gimple_code (stmt) != GIMPLE_ASSIGN)
+ /* Only consider code == GIMPLE_ASSIGN. */
+ gimple_assign stmt = gsi_stmt (*gsi)->dyn_cast_gimple_assign ();
+ if (!stmt)
return;
code = gimple_assign_rhs_code (stmt);
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index f0020ee..ae6fbbc 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -3507,7 +3507,7 @@ extract_range_from_unary_expr (value_range_t *vr, enum tree_code code,
the ranges of each of its operands and the expression code. */
static void
-extract_range_from_cond_expr (value_range_t *vr, gimple stmt)
+extract_range_from_cond_expr (value_range_t *vr, gimple_assign stmt)
{
tree op0, op1;
value_range_t vr0 = VR_INITIALIZER;
@@ -3814,7 +3814,7 @@ extract_range_basic (value_range_t *vr, gimple stmt)
in *VR. */
static void
-extract_range_from_assignment (value_range_t *vr, gimple stmt)
+extract_range_from_assignment (value_range_t *vr, gimple_assign stmt)
{
enum tree_code code = gimple_assign_rhs_code (stmt);
@@ -6794,7 +6794,7 @@ vrp_visit_assignment_or_call (gimple stmt, tree *output_p)
else if (code == GIMPLE_CALL)
extract_range_basic (&new_vr, stmt);
else
- extract_range_from_assignment (&new_vr, stmt);
+ extract_range_from_assignment (&new_vr, stmt->as_a_gimple_assign ());
if (update_value_range (lhs, &new_vr))
{
@@ -9463,16 +9463,16 @@ simplify_stmt_for_jump_threading (gimple stmt, gimple within_stmt)
gimple_cond_lhs (stmt),
gimple_cond_rhs (stmt), within_stmt);
- if (gimple_code (stmt) == GIMPLE_ASSIGN)
+ if (gimple_assign assign_stmt = stmt->dyn_cast_gimple_assign ())
{
value_range_t new_vr = VR_INITIALIZER;
- tree lhs = gimple_assign_lhs (stmt);
+ tree lhs = gimple_assign_lhs (assign_stmt);
if (TREE_CODE (lhs) == SSA_NAME
&& (INTEGRAL_TYPE_P (TREE_TYPE (lhs))
|| POINTER_TYPE_P (TREE_TYPE (lhs))))
{
- extract_range_from_assignment (&new_vr, stmt);
+ extract_range_from_assignment (&new_vr, assign_stmt);
if (range_int_cst_singleton_p (&new_vr))
return new_vr.min;
}
--
1.7.11.7