diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-11-05 12:17:10 +0000 |
---|---|---|
committer | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-11-05 12:17:10 +0000 |
commit | fb8ed03fa605f7ccb18283a22a90c6cae7a8340c (patch) | |
tree | c33b55ff21ac34fcc6846d0faa6ad347ae2c4bde /gcc/tree-ssa-forwprop.c | |
parent | acd4810591d645ed34cbc20766fd71bad74166f1 (diff) | |
download | gcc-fb8ed03fa605f7ccb18283a22a90c6cae7a8340c.tar.gz |
2008-11-05 Richard Guenther <rguenther@suse.de>
PR middle-end/37742
* tree-ssa.c (useless_type_conversion_p_1): Check different restrict
qualified pointer conversion before stripping qualifiers.
* gimplify.c (create_tmp_from_val): Use correctly qualified type.
* tree-flow.h (may_propagate_address_into_dereference): Declare.
* tree-ssa-ccp.c (may_propagate_address_into_dereference): New function.
(ccp_fold): Use it.
* tree-ssa-forwprop.c (rhs_to_tree): Remove useless conversions,
properly canonicalize binary ops.
(forward_propagate_addr_expr_1): Use
may_propagate_address_into_dereference.
cp/
* decl.c (start_preparsed_function): Use the correct type for
building the RESULT_DECL.
* gcc.c-torture/compile/pr37742.c: New testcase.
* g++.dg/pr37742.C: Likewise.
* gcc.dg/tree-ssa/forwprop-7.c: Check for two volatile loads.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@141606 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-forwprop.c')
-rw-r--r-- | gcc/tree-ssa-forwprop.c | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c index 7a5233bd1f8..a04e7ca4404 100644 --- a/gcc/tree-ssa-forwprop.c +++ b/gcc/tree-ssa-forwprop.c @@ -334,10 +334,10 @@ rhs_to_tree (tree type, gimple stmt) { enum tree_code code = gimple_assign_rhs_code (stmt); if (get_gimple_rhs_class (code) == GIMPLE_BINARY_RHS) - return fold_convert (type, build2 (code, type, gimple_assign_rhs1 (stmt), - gimple_assign_rhs2 (stmt))); + return fold_build2 (code, type, gimple_assign_rhs1 (stmt), + gimple_assign_rhs2 (stmt)); else if (get_gimple_rhs_class (code) == GIMPLE_UNARY_RHS) - return fold_convert (type, build1 (code, type, gimple_assign_rhs1 (stmt))); + return build1 (code, type, gimple_assign_rhs1 (stmt)); else if (get_gimple_rhs_class (code) == GIMPLE_SINGLE_RHS) return gimple_assign_rhs1 (stmt); else @@ -719,12 +719,7 @@ forward_propagate_addr_expr_1 (tree name, tree def_rhs, propagate the ADDR_EXPR into the use of NAME and fold the result. */ if (TREE_CODE (lhs) == INDIRECT_REF && TREE_OPERAND (lhs, 0) == name - && useless_type_conversion_p (TREE_TYPE (TREE_OPERAND (lhs, 0)), - TREE_TYPE (def_rhs)) - /* ??? This looks redundant, but is required for bogus types - that can sometimes occur. */ - && useless_type_conversion_p (TREE_TYPE (lhs), - TREE_TYPE (TREE_OPERAND (def_rhs, 0)))) + && may_propagate_address_into_dereference (def_rhs, lhs)) { *lhsp = unshare_expr (TREE_OPERAND (def_rhs, 0)); fold_stmt_inplace (use_stmt); @@ -747,12 +742,7 @@ forward_propagate_addr_expr_1 (tree name, tree def_rhs, propagate the ADDR_EXPR into the use of NAME and fold the result. */ if (TREE_CODE (rhs) == INDIRECT_REF && TREE_OPERAND (rhs, 0) == name - && useless_type_conversion_p (TREE_TYPE (TREE_OPERAND (rhs, 0)), - TREE_TYPE (def_rhs)) - /* ??? This looks redundant, but is required for bogus types - that can sometimes occur. */ - && useless_type_conversion_p (TREE_TYPE (rhs), - TREE_TYPE (TREE_OPERAND (def_rhs, 0)))) + && may_propagate_address_into_dereference (def_rhs, rhs)) { *rhsp = unshare_expr (TREE_OPERAND (def_rhs, 0)); fold_stmt_inplace (use_stmt); |