* tree-parloops.c (take_address_of): Add GSI argument. Return NULL
if it is NULL and uid wasn't found in the hash table. Just fold the
result if it is NULL otherwise. Insert other potentially needed
stmts right before current stmt instead of on the entry edge.
(struct elv_data): Add gsi and reset fields.
(eliminate_local_variables_1): Adjust caller. If take_address_of
failed for debug stmt, set dta->reset and return.
(eliminate_local_variables_stmt): Change STMT argument for GSI,
pass GSI through to the callback, handle resetting of debug stmts.
(eliminate_local_variables): Adjust caller. Process debug stmts
in second phase.
* gcc.dg/autopar/pr46099.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@166355
138bc75d-0d04-0410-961f-
82ee72b054a4
* cfgexpand.c (expand_debug_expr): Handle MEM_REF
with non-zero offset.
* cfgexpand.c (expand_debug_expr): Handle MEM_REF
with non-zero offset.
+ PR tree-optimization/46099
+ * tree-parloops.c (take_address_of): Add GSI argument. Return NULL
+ if it is NULL and uid wasn't found in the hash table. Just fold the
+ result if it is NULL otherwise. Insert other potentially needed
+ stmts right before current stmt instead of on the entry edge.
+ (struct elv_data): Add gsi and reset fields.
+ (eliminate_local_variables_1): Adjust caller. If take_address_of
+ failed for debug stmt, set dta->reset and return.
+ (eliminate_local_variables_stmt): Change STMT argument for GSI,
+ pass GSI through to the callback, handle resetting of debug stmts.
+ (eliminate_local_variables): Adjust caller. Process debug stmts
+ in second phase.
+
PR middle-end/43690
* gimplify.c (gimplify_asm_expr): If a "m" input is a
{pre,post}{in,de}crement, fail.
PR middle-end/43690
* gimplify.c (gimplify_asm_expr): If a "m" input is a
{pre,post}{in,de}crement, fail.
2010-11-05 Jakub Jelinek <jakub@redhat.com>
2010-11-05 Jakub Jelinek <jakub@redhat.com>
+ PR tree-optimization/46099
+ * gcc.dg/autopar/pr46099.c: New test.
+
PR middle-end/43690
* c-c++-common/pr43690.c: New test.
PR middle-end/43690
* c-c++-common/pr43690.c: New test.
--- /dev/null
+/* PR tree-optimization/46099 */
+/* { dg-do compile } */
+/* { dg-options "-ftree-parallelize-loops=2 -fcompare-debug -O" } */
+
+static inline void
+bar (int *i)
+{
+ int j = *i;
+}
+
+void baz (int *, int *, int *);
+
+void
+f1 (int n)
+{
+ int i;
+ for (i = 0; i < n; i++)
+ bar (&i);
+}
+
+void
+f2 (int n)
+{
+ int i;
+ int a[10000], b[10000], c[10000];
+ baz (a, b, c);
+ for (i = 0; i < n; i++)
+ {
+ void *p = c;
+ a[i] = b[i] + c[i];
+ }
+ baz (a, b, c);
+}
+
+void
+f3 (int n)
+{
+ int i;
+ int a[10000], b[10000], c[10000];
+ baz (a, b, c);
+ for (i = 0; i < n; i++)
+ {
+ a[i] = b[i] + c[i];
+ void *p = c;
+ }
+ baz (a, b, c);
+}
/* Assigns the address of OBJ in TYPE to an ssa name, and returns this name.
The assignment statement is placed on edge ENTRY. DECL_ADDRESS maps decls
to their addresses that can be reused. The address of OBJ is known to
/* Assigns the address of OBJ in TYPE to an ssa name, and returns this name.
The assignment statement is placed on edge ENTRY. DECL_ADDRESS maps decls
to their addresses that can be reused. The address of OBJ is known to
- be invariant in the whole function. */
+ be invariant in the whole function. Other needed statements are placed
+ right before GSI. */
-take_address_of (tree obj, tree type, edge entry, htab_t decl_address)
+take_address_of (tree obj, tree type, edge entry, htab_t decl_address,
+ gimple_stmt_iterator *gsi)
dslot = htab_find_slot_with_hash (decl_address, &ielt, uid, INSERT);
if (!*dslot)
{
dslot = htab_find_slot_with_hash (decl_address, &ielt, uid, INSERT);
if (!*dslot)
{
+ if (gsi == NULL)
+ return NULL;
addr = TREE_OPERAND (*var_p, 0);
bvar = create_tmp_var (TREE_TYPE (addr),
get_name (TREE_OPERAND
addr = TREE_OPERAND (*var_p, 0);
bvar = create_tmp_var (TREE_TYPE (addr),
get_name (TREE_OPERAND
/* Express the address in terms of the canonical SSA name. */
TREE_OPERAND (*var_p, 0) = name;
/* Express the address in terms of the canonical SSA name. */
TREE_OPERAND (*var_p, 0) = name;
+ if (gsi == NULL)
+ return build_fold_addr_expr_with_type (obj, type);
+
name = force_gimple_operand (build_addr (obj, current_function_decl),
&stmts, true, NULL_TREE);
if (!gimple_seq_empty_p (stmts))
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);
+ gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT);
if (!useless_type_conversion_p (type, TREE_TYPE (name)))
{
name = force_gimple_operand (fold_convert (type, name), &stmts, true,
NULL_TREE);
if (!gimple_seq_empty_p (stmts))
if (!useless_type_conversion_p (type, TREE_TYPE (name)))
{
name = force_gimple_operand (fold_convert (type, name), &stmts, true,
NULL_TREE);
if (!gimple_seq_empty_p (stmts))
- gsi_insert_seq_on_edge_immediate (entry, stmts);
+ gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT);
struct walk_stmt_info info;
edge entry;
htab_t decl_address;
struct walk_stmt_info info;
edge entry;
htab_t decl_address;
+ gimple_stmt_iterator *gsi;
};
/* Eliminates references to local variables in *TP out of the single
};
/* Eliminates references to local variables in *TP out of the single
type = TREE_TYPE (t);
addr_type = build_pointer_type (type);
type = TREE_TYPE (t);
addr_type = build_pointer_type (type);
- addr = take_address_of (t, addr_type, dta->entry, dta->decl_address);
+ addr = take_address_of (t, addr_type, dta->entry, dta->decl_address,
+ dta->gsi);
+ if (dta->gsi == NULL && addr == NULL_TREE)
+ {
+ dta->reset = true;
+ return NULL_TREE;
+ }
+
*tp = build_simple_mem_ref (addr);
dta->changed = true;
*tp = build_simple_mem_ref (addr);
dta->changed = true;
return NULL_TREE;
addr_type = TREE_TYPE (t);
return NULL_TREE;
addr_type = TREE_TYPE (t);
- addr = take_address_of (obj, addr_type, dta->entry, dta->decl_address);
+ addr = take_address_of (obj, addr_type, dta->entry, dta->decl_address,
+ dta->gsi);
+ if (dta->gsi == NULL && addr == NULL_TREE)
+ {
+ dta->reset = true;
+ return NULL_TREE;
+ }
*tp = addr;
dta->changed = true;
*tp = addr;
dta->changed = true;
-/* Moves the references to local variables in STMT out of the single
+/* Moves the references to local variables in STMT at *GSI out of the single
entry single exit region starting at ENTRY. DECL_ADDRESS contains
addresses of the references that had their address taken
already. */
static void
entry single exit region starting at ENTRY. DECL_ADDRESS contains
addresses of the references that had their address taken
already. */
static void
-eliminate_local_variables_stmt (edge entry, gimple stmt,
+eliminate_local_variables_stmt (edge entry, gimple_stmt_iterator *gsi,
htab_t decl_address)
{
struct elv_data dta;
htab_t decl_address)
{
struct elv_data dta;
+ gimple stmt = gsi_stmt (*gsi);
memset (&dta.info, '\0', sizeof (dta.info));
dta.entry = entry;
dta.decl_address = decl_address;
dta.changed = false;
memset (&dta.info, '\0', sizeof (dta.info));
dta.entry = entry;
dta.decl_address = decl_address;
dta.changed = false;
if (gimple_debug_bind_p (stmt))
if (gimple_debug_bind_p (stmt))
- walk_tree (gimple_debug_bind_get_value_ptr (stmt),
- eliminate_local_variables_1, &dta.info, NULL);
+ {
+ dta.gsi = NULL;
+ walk_tree (gimple_debug_bind_get_value_ptr (stmt),
+ eliminate_local_variables_1, &dta.info, NULL);
+ if (dta.reset)
+ {
+ gimple_debug_bind_reset_value (stmt);
+ dta.changed = true;
+ }
+ }
- walk_gimple_op (stmt, eliminate_local_variables_1, &dta.info);
+ {
+ dta.gsi = gsi;
+ walk_gimple_op (stmt, eliminate_local_variables_1, &dta.info);
+ }
if (dta.changed)
update_stmt (stmt);
if (dta.changed)
update_stmt (stmt);
VEC (basic_block, heap) *body = VEC_alloc (basic_block, heap, 3);
unsigned i;
gimple_stmt_iterator gsi;
VEC (basic_block, heap) *body = VEC_alloc (basic_block, heap, 3);
unsigned i;
gimple_stmt_iterator gsi;
+ bool has_debug_stmt = false;
htab_t decl_address = htab_create (10, int_tree_map_hash, int_tree_map_eq,
free);
basic_block entry_bb = entry->src;
htab_t decl_address = htab_create (10, int_tree_map_hash, int_tree_map_eq,
free);
basic_block entry_bb = entry->src;
FOR_EACH_VEC_ELT (basic_block, body, i, bb)
if (bb != entry_bb && bb != exit_bb)
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
FOR_EACH_VEC_ELT (basic_block, body, i, bb)
if (bb != entry_bb && bb != exit_bb)
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
- eliminate_local_variables_stmt (entry, gsi_stmt (gsi),
- decl_address);
+ if (gimple_debug_bind_p (gsi_stmt (gsi)))
+ has_debug_stmt = true;
+ else
+ eliminate_local_variables_stmt (entry, &gsi, decl_address);
+
+ if (has_debug_stmt)
+ FOR_EACH_VEC_ELT (basic_block, body, i, bb)
+ if (bb != entry_bb && bb != exit_bb)
+ for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+ if (gimple_debug_bind_p (gsi_stmt (gsi)))
+ eliminate_local_variables_stmt (entry, &gsi, decl_address);
htab_delete (decl_address);
VEC_free (basic_block, heap, body);
htab_delete (decl_address);
VEC_free (basic_block, heap, body);