aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2008-11-21 22:59:33 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2008-11-21 22:59:33 +0100
commit88e091c3372048f6c3b3d41cbfedf422b5496808 (patch)
treec0dad29bcfb209c5ed0c46b8e8b2cc20e4bdba85 /gcc
parent0e51e769b52cb4c91339a0eef5fa6a70c0ee2dde (diff)
downloadgcc-88e091c3372048f6c3b3d41cbfedf422b5496808.zip
gcc-88e091c3372048f6c3b3d41cbfedf422b5496808.tar.gz
gcc-88e091c3372048f6c3b3d41cbfedf422b5496808.tar.bz2
re PR middle-end/38200 (internal compiler error: in find_func_aliases, at tree-ssa-structalias.c:3905)
PR middle-end/38200 * tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Only propagate x = &a into *x = b if conversion from b to a's type is useless. * gcc.dg/pr38200.c: New test. From-SVN: r142100
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/pr38200.c16
-rw-r--r--gcc/tree-ssa-forwprop.c32
4 files changed, 38 insertions, 22 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 1f0b3fc..e4790f1 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2008-11-21 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/38200
+ * tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Only
+ propagate x = &a into *x = b if conversion from b to a's type is
+ useless.
+
2008-11-21 Eric Botcazou <ebotcazou@adacore.com>
* caller-save.c (insert_one_insn): Take into account REG_INC notes
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 3f99b5a..c9e449f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2008-11-21 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/38200
+ * gcc.dg/pr38200.c: New test.
+
2008-11-21 H.J. Lu <hongjiu.lu@intel.com>
* gcc.target/i386/avx-1.c: Include <immintrin.h> instead of
diff --git a/gcc/testsuite/gcc.dg/pr38200.c b/gcc/testsuite/gcc.dg/pr38200.c
new file mode 100644
index 0000000..d5391bd
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr38200.c
@@ -0,0 +1,16 @@
+/* PR middle-end/38200 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-strict-aliasing" } */
+
+typedef int (*callptr) (void);
+int foo (void **x);
+void foo2 (callptr *);
+int (*foo_ptr) (void **x) = foo;
+
+void
+bar (void)
+{
+ void *ptr;
+ foo2 ((callptr *) &ptr);
+ *(void **) &foo_ptr = ptr;
+}
diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c
index 333ef82..b19879f 100644
--- a/gcc/tree-ssa-forwprop.c
+++ b/gcc/tree-ssa-forwprop.c
@@ -719,30 +719,18 @@ 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
- && may_propagate_address_into_dereference (def_rhs, lhs))
+ && may_propagate_address_into_dereference (def_rhs, lhs)
+ && (lhsp != gimple_assign_lhs_ptr (use_stmt)
+ || useless_type_conversion_p (TREE_TYPE (TREE_OPERAND (def_rhs, 0)),
+ TREE_TYPE (rhs))))
{
- bool valid = true;
- if (lhsp == gimple_assign_lhs_ptr (use_stmt)
- && !useless_type_conversion_p (TREE_TYPE (TREE_OPERAND (def_rhs, 0)),
- TREE_TYPE (rhs))
- && !CONVERT_EXPR_CODE_P (rhs_code))
- {
- if (rhs_code == SSA_NAME)
- gimple_assign_set_rhs_code (use_stmt, NOP_EXPR);
- else
- valid = false;
- }
- if (valid)
- {
- *lhsp = unshare_expr (TREE_OPERAND (def_rhs, 0));
- fold_stmt_inplace (use_stmt);
- tidy_after_forward_propagate_addr (use_stmt);
+ *lhsp = unshare_expr (TREE_OPERAND (def_rhs, 0));
+ fold_stmt_inplace (use_stmt);
+ tidy_after_forward_propagate_addr (use_stmt);
- /* Continue propagating into the RHS if this was not the only
- use. */
- if (single_use_p)
- return true;
- }
+ /* Continue propagating into the RHS if this was not the only use. */
+ if (single_use_p)
+ return true;
}
/* Strip away any outer COMPONENT_REF, ARRAY_REF or ADDR_EXPR