aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-forwprop.c
diff options
context:
space:
mode:
authorAndrew Pinski <andrew_pinski@playstation.sony.com>2009-01-20 17:10:40 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2009-01-20 17:10:40 +0000
commit37348bf1059789a055e87113553bdda141db5cd0 (patch)
tree724475a560b4dd068a277f34c223a8bf205b5837 /gcc/tree-ssa-forwprop.c
parentd0a589040b272bdc1adafd3a268d0903d418e1aa (diff)
downloadgcc-37348bf1059789a055e87113553bdda141db5cd0.zip
gcc-37348bf1059789a055e87113553bdda141db5cd0.tar.gz
gcc-37348bf1059789a055e87113553bdda141db5cd0.tar.bz2
re PR tree-optimization/38747 (Wrong code due to VIEW_CONVERT_EXPR)
2009-01-20 Andrew Pinski <andrew_pinski@playstation.sony.com> Richard Guenther <rguenther@suse.de> PR tree-optimization/38747 PR tree-optimization/38748 * tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Disable the VCE conversion if the base address is an indirect reference and the aliasing sets could cause issues. * gcc.dg/tree-ssa/struct-aliasing-1.c: New test. * gcc.dg/tree-ssa/struct-aliasing-2.c: Likewise. * gcc.c-torture/execute/struct-aliasing-1.c: Likewise. Co-Authored-By: Richard Guenther <rguenther@suse.de> From-SVN: r143523
Diffstat (limited to 'gcc/tree-ssa-forwprop.c')
-rw-r--r--gcc/tree-ssa-forwprop.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c
index bfd7146..3826f1a 100644
--- a/gcc/tree-ssa-forwprop.c
+++ b/gcc/tree-ssa-forwprop.c
@@ -777,7 +777,7 @@ 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))
{
- tree new_rhs = unshare_expr (TREE_OPERAND (def_rhs, 0));
+ tree def_rhs_base, 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)
{
@@ -788,16 +788,23 @@ forward_propagate_addr_expr_1 (tree name, tree def_rhs,
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);
+ tidy_after_forward_propagate_addr (use_stmt);
+ return true;
}
- else
+ /* If the defining rhs comes from an indirect reference, then do not
+ convert into a VIEW_CONVERT_EXPR. */
+ def_rhs_base = TREE_OPERAND (def_rhs, 0);
+ while (handled_component_p (def_rhs_base))
+ def_rhs_base = TREE_OPERAND (def_rhs_base, 0);
+ if (!INDIRECT_REF_P (def_rhs_base))
{
/* 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;
}
- tidy_after_forward_propagate_addr (use_stmt);
- return true;
}
/* If the use of the ADDR_EXPR is not a POINTER_PLUS_EXPR, there