summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2010-10-21 10:38:51 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2010-10-21 10:38:51 +0000
commit64ade643f95b4ac26889a6863f81e7dfe50d5e34 (patch)
tree8909773836d8ee38d61ed03b1fa807fcd0296206
parent4aed540562efe2aad5c88db9dabb4ef36296ccc2 (diff)
downloadgcc-64ade643f95b4ac26889a6863f81e7dfe50d5e34.tar.gz
2010-10-21 Richard Guenther <rguenther@suse.de>
PR tree-optimization/46111 * tree-parloops.c (take_address_of): Re-organize for MEM_REF. * g++.dg/torture/pr46111.C: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@165765 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/torture/pr46111.C31
-rw-r--r--gcc/tree-parloops.c31
4 files changed, 60 insertions, 12 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 44995af48c8..8fc317f1e3d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2010-10-21 Richard Guenther <rguenther@suse.de>
+
+ PR tree-optimization/46111
+ * tree-parloops.c (take_address_of): Re-organize for MEM_REF.
+
2010-10-21 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
* config/s390/s390.md (*xordi3_cc): Mark xgrk as z196 only.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 7d1dbb9dfef..78d4bc1c6cd 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2010-10-21 Richard Guenther <rguenther@suse.de>
+
+ PR tree-optimization/46111
+ * g++.dg/torture/pr46111.C: New testcase.
+
2010-10-21 Janus Weil <janus@gcc.gnu.org>
PR fortran/46067
diff --git a/gcc/testsuite/g++.dg/torture/pr46111.C b/gcc/testsuite/g++.dg/torture/pr46111.C
new file mode 100644
index 00000000000..c1b04a03fa5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr46111.C
@@ -0,0 +1,31 @@
+// { dg-do compile }
+// { dg-options "-ftree-parallelize-loops=2 -g" }
+
+struct A
+{
+ int zero ()
+ {
+ return 0;
+ }
+};
+
+static inline void
+bar (int)
+{
+}
+
+struct B
+{
+ struct A a;
+ B (int n)
+ {
+ for (int i = 0; i < n; i++)
+ bar (a.zero ());
+ }
+};
+
+void
+foo (int n)
+{
+ struct B b (n);
+}
diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c
index b25b2082922..de9faefe778 100644
--- a/gcc/tree-parloops.c
+++ b/gcc/tree-parloops.c
@@ -333,14 +333,23 @@ take_address_of (tree obj, tree type, edge entry, htab_t decl_address)
handled_component_p (*var_p);
var_p = &TREE_OPERAND (*var_p, 0))
continue;
- uid = DECL_UID (*var_p);
+ /* Canonicalize the access to base on a MEM_REF. */
+ if (DECL_P (*var_p))
+ *var_p = build_simple_mem_ref (build_fold_addr_expr (*var_p));
+
+ /* Assign a canonical SSA name to the address of the base decl used
+ in the address and share it for all accesses and addresses based
+ on it. */
+ uid = DECL_UID (TREE_OPERAND (TREE_OPERAND (*var_p, 0), 0));
ielt.uid = uid;
dslot = htab_find_slot_with_hash (decl_address, &ielt, uid, INSERT);
if (!*dslot)
{
- addr = build_addr (*var_p, current_function_decl);
- bvar = create_tmp_var (TREE_TYPE (addr), get_name (*var_p));
+ addr = TREE_OPERAND (*var_p, 0);
+ bvar = create_tmp_var (TREE_TYPE (addr),
+ get_name (TREE_OPERAND
+ (TREE_OPERAND (*var_p, 0), 0)));
add_referenced_var (bvar);
stmt = gimple_build_assign (bvar, addr);
name = make_ssa_name (bvar, stmt);
@@ -355,16 +364,14 @@ take_address_of (tree obj, tree type, edge entry, htab_t decl_address)
else
name = ((struct int_tree_map *) *dslot)->to;
- if (var_p != &obj)
- {
- *var_p = build_simple_mem_ref (name);
- name = force_gimple_operand (build_addr (obj, current_function_decl),
- &stmts, true, NULL_TREE);
- if (!gimple_seq_empty_p (stmts))
- gsi_insert_seq_on_edge_immediate (entry, stmts);
- }
+ /* Express the address in terms of the canonical SSA name. */
+ TREE_OPERAND (*var_p, 0) = name;
+ name = force_gimple_operand (build_addr (obj, current_function_decl),
+ &stmts, true, NULL_TREE);
+ if (!gimple_seq_empty_p (stmts))
+ gsi_insert_seq_on_edge_immediate (entry, stmts);
- if (TREE_TYPE (name) != type)
+ if (!useless_type_conversion_p (type, TREE_TYPE (name)))
{
name = force_gimple_operand (fold_convert (type, name), &stmts, true,
NULL_TREE);