aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-forwprop.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2008-10-18 18:06:41 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2008-10-18 18:06:41 +0000
commit73a5f1995f887b8511c8168d00149e7da92cf77f (patch)
tree4fd74938520320c45dcbb0803de64867f7b9d032 /gcc/tree-ssa-forwprop.c
parent8168c08f08e2e309c855793dde24757acaceb8ec (diff)
downloadgcc-73a5f1995f887b8511c8168d00149e7da92cf77f.zip
gcc-73a5f1995f887b8511c8168d00149e7da92cf77f.tar.gz
gcc-73a5f1995f887b8511c8168d00149e7da92cf77f.tar.bz2
tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Guard VIEW_CONVERT_EXPR case against invalid gimple.
2008-10-18 Richard Guenther <rguenther@suse.de> * tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Guard VIEW_CONVERT_EXPR case against invalid gimple. From-SVN: r141212
Diffstat (limited to 'gcc/tree-ssa-forwprop.c')
-rw-r--r--gcc/tree-ssa-forwprop.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c
index 3513ee0..7a5233b 100644
--- a/gcc/tree-ssa-forwprop.c
+++ b/gcc/tree-ssa-forwprop.c
@@ -767,8 +767,8 @@ forward_propagate_addr_expr_1 (tree name, tree def_rhs,
&& TREE_OPERAND (rhs, 0) == name
&& TYPE_SIZE (TREE_TYPE (rhs))
&& TYPE_SIZE (TREE_TYPE (TREE_OPERAND (def_rhs, 0)))
- /* Function decls should not be used for VCE either as it could be
- a function descriptor that we want and not the actual function code. */
+ /* Function decls should not be used for VCE either as it could be a
+ function descriptor that we want and not the actual function code. */
&& TREE_CODE (TREE_OPERAND (def_rhs, 0)) != FUNCTION_DECL
/* We should not convert volatile loads to non volatile loads. */
&& !TYPE_VOLATILE (TREE_TYPE (rhs))
@@ -776,22 +776,27 @@ forward_propagate_addr_expr_1 (tree name, tree def_rhs,
&& operand_equal_p (TYPE_SIZE (TREE_TYPE (rhs)),
TYPE_SIZE (TREE_TYPE (TREE_OPERAND (def_rhs, 0))), 0))
{
- bool res = true;
- tree new_rhs = unshare_expr (TREE_OPERAND (def_rhs, 0));
- new_rhs = fold_build1 (VIEW_CONVERT_EXPR, TREE_TYPE (rhs), new_rhs);
- /* If we have folded the VCE, then we have to create a new statement. */
- if (TREE_CODE (new_rhs) != VIEW_CONVERT_EXPR)
- {
- gimple_stmt_iterator gsi = gsi_for_stmt (use_stmt);
- new_rhs = force_gimple_operand_gsi (&gsi, new_rhs, true, NULL, true, GSI_SAME_STMT);
- /* As we change the deference to a SSA_NAME, we need to return false to make sure that
- the statement does not get removed. */
- res = false;
- }
- *rhsp = new_rhs;
- fold_stmt_inplace (use_stmt);
- tidy_after_forward_propagate_addr (use_stmt);
- return res;
+ tree new_rhs = unshare_expr (TREE_OPERAND (def_rhs, 0));
+ new_rhs = fold_build1 (VIEW_CONVERT_EXPR, TREE_TYPE (rhs), new_rhs);
+ if (TREE_CODE (new_rhs) != VIEW_CONVERT_EXPR)
+ {
+ /* If we have folded the VIEW_CONVERT_EXPR then the result is only
+ valid if we can replace the whole rhs of the use statement. */
+ if (rhs != gimple_assign_rhs1 (use_stmt))
+ return false;
+ new_rhs = force_gimple_operand_gsi (use_stmt_gsi, new_rhs, true, NULL,
+ true, GSI_NEW_STMT);
+ gimple_assign_set_rhs1 (use_stmt, new_rhs);
+ }
+ else
+ {
+ /* We may have arbitrary VIEW_CONVERT_EXPRs in a nested component
+ reference. Place it there and fold the thing. */
+ *rhsp = new_rhs;
+ fold_stmt_inplace (use_stmt);
+ }
+ tidy_after_forward_propagate_addr (use_stmt);
+ return true;
}
/* If the use of the ADDR_EXPR is not a POINTER_PLUS_EXPR, there