[tuples] stomp out more openmp regressions
Aldy Hernandez
aldyh@redhat.com
Tue May 13 10:33:00 GMT 2008
I fixed a handful of errors in how we were walking the OMP statements.
It turns out walk_tree's walk_subtrees is the opposite of walk_stmt's
handled_ops_p.
I also fixed some pretty printer issues, and some CFG problems wrt OMP.
This patch fixes about 180 regressions.
Committing to b-r-a-n-c-h. Phew.
Aldy
* omp-low.c (scan_omp_op): Remove walk_subtrees. Call walk_tree.
(scan_omp_for): Scan OMP body.
(scan_omp_1_stmt): Set handled_ops_p.
(expand_omp_parallel): Parse ADDR_EXPR correctly.
(diagnose_sb_1): Rename walk_subtrees to handled_ops_p and set
appropriately.
(diagnose_sb_2): Same.
* gimple-pretty-print.c (dump_gimple_omp_for): Print braces around
OMP body.
* tree-inline.c (estimate_num_insns): GIMPLE_OMP_CONTINUE does not
have a body.
* tree-cfg.c (move_stmt_op): Parse move_stmt_d out of data correctly.
(move_stmt_r): Rename walk_subtrees to handled_ops_p and set
appropriately.
Index: omp-low.c
===================================================================
--- omp-low.c (revision 135258)
+++ omp-low.c (working copy)
@@ -135,13 +135,12 @@ static inline tree
scan_omp_op (tree *tp, omp_context *ctx)
{
struct walk_stmt_info wi;
- int walk_subtrees = 1;
memset (&wi, 0, sizeof (wi));
wi.info = ctx;
wi.want_locations = true;
- return scan_omp_1_op (tp, &walk_subtrees, &wi);
+ return walk_tree (tp, scan_omp_1_op, &wi, NULL);
}
static void lower_omp (gimple_seq, omp_context *);
@@ -1285,6 +1284,7 @@ scan_omp_for (gimple stmt, omp_context *
scan_omp_op (gimple_omp_for_initial_ptr (stmt), ctx);
scan_omp_op (gimple_omp_for_final_ptr (stmt), ctx);
scan_omp_op (gimple_omp_for_incr_ptr (stmt), ctx);
+ scan_omp (gimple_omp_body (stmt), ctx);
}
/* Scan an OpenMP sections directive. */
@@ -1455,6 +1455,8 @@ scan_omp_1_stmt (gimple_stmt_iterator *g
if (is_gimple_omp (stmt) && ctx != NULL)
check_omp_nesting_restrictions (stmt, ctx);
+ *handled_ops_p = true;
+
switch (gimple_code (stmt))
{
case GIMPLE_OMP_PARALLEL:
@@ -1487,15 +1489,17 @@ scan_omp_1_stmt (gimple_stmt_iterator *g
{
tree var;
- for (var = gimple_bind_vars (stmt); var ; var = TREE_CHAIN (var))
- insert_decl_map (&ctx->cb, var, var);
+ *handled_ops_p = false;
+ if (ctx)
+ for (var = gimple_bind_vars (stmt); var ; var = TREE_CHAIN (var))
+ insert_decl_map (&ctx->cb, var, var);
}
break;
default:
+ *handled_ops_p = false;
break;
}
- *handled_ops_p = false;
return NULL_TREE;
}
@@ -2653,7 +2657,7 @@ expand_omp_parallel (struct omp_region *
continue;
if (gimple_subcode (stmt) == ADDR_EXPR
- && gimple_assign_rhs1 (stmt)
+ && TREE_OPERAND (gimple_assign_rhs1 (stmt), 0)
== gimple_omp_parallel_data_arg (entry_stmt))
{
parcopy_stmt = stmt;
@@ -5235,14 +5239,14 @@ diagnose_sb_0 (gimple_stmt_iterator *gsi
where each label is found. */
static tree
-diagnose_sb_1 (gimple_stmt_iterator *gsi_p, bool *walk_subtrees,
+diagnose_sb_1 (gimple_stmt_iterator *gsi_p, bool *handled_ops_p,
struct walk_stmt_info *wi)
{
gimple context = (gimple) wi->info;
gimple inner_context;
gimple stmt = gsi_stmt (*gsi_p);
- *walk_subtrees = false;
+ *handled_ops_p = true;
switch (gimple_code (stmt))
{
@@ -5287,14 +5291,15 @@ diagnose_sb_1 (gimple_stmt_iterator *gsi
the destination label's context. */
static tree
-diagnose_sb_2 (gimple_stmt_iterator *gsi_p, bool *walk_subtrees,
+diagnose_sb_2 (gimple_stmt_iterator *gsi_p, bool *handled_ops_p,
struct walk_stmt_info *wi)
{
gimple context = (gimple) wi->info;
splay_tree_node n;
gimple stmt = gsi_stmt (*gsi_p);
- *walk_subtrees = false;
+ *handled_ops_p = true;
+
switch (gimple_code (stmt))
{
case GIMPLE_OMP_PARALLEL:
@@ -5344,7 +5349,8 @@ diagnose_sb_2 (gimple_stmt_iterator *gsi
break;
case GIMPLE_RETURN:
- diagnose_sb_0 (gsi_p, context, NULL);
+ if (!context)
+ diagnose_sb_0 (gsi_p, context, NULL);
break;
default:
Index: gimple-pretty-print.c
===================================================================
--- gimple-pretty-print.c (revision 135258)
+++ gimple-pretty-print.c (working copy)
@@ -746,8 +746,15 @@ dump_gimple_omp_for (pretty_printer *buf
dump_generic_node (buffer, gimple_omp_for_incr (gs), spc, flags, false);
pp_character (buffer, ')');
- newline_and_indent (buffer, spc + 2);
- dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 2, flags);
+ if (!gimple_seq_empty_p (gimple_omp_body (gs)))
+ {
+ newline_and_indent (buffer, spc + 2);
+ pp_character (buffer, '{');
+ newline_and_indent (buffer, spc + 4);
+ dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
+ newline_and_indent (buffer, spc + 2);
+ pp_character (buffer, '}');
+ }
}
}
Index: tree-inline.c
===================================================================
--- tree-inline.c (revision 135258)
+++ tree-inline.c (working copy)
@@ -2874,13 +2874,13 @@ estimate_num_insns (gimple stmt, eni_wei
+ estimate_num_insns_seq (gimple_try_cleanup (stmt), weights));
/* OpenMP directives are generally very expensive. */
+
case GIMPLE_OMP_RETURN:
case GIMPLE_OMP_SECTIONS_SWITCH:
case GIMPLE_OMP_ATOMIC_STORE:
- return 0;
-
case GIMPLE_OMP_CONTINUE:
- return estimate_num_insns_seq (gimple_omp_body (stmt), weights);
+ /* ...except these, which are cheap. */
+ return 0;
case GIMPLE_OMP_ATOMIC_LOAD:
return weights->omp_cost;
Index: tree-cfg.c
===================================================================
--- tree-cfg.c (revision 135258)
+++ tree-cfg.c (working copy)
@@ -5263,7 +5263,8 @@ struct move_stmt_d
static tree
move_stmt_op (tree *tp, int *walk_subtrees, void *data)
{
- struct move_stmt_d *p = (struct move_stmt_d *) data;
+ struct walk_stmt_info *wi = (struct walk_stmt_info *) data;
+ struct move_stmt_d *p = wi->info;
tree t = *tp;
if (p->block
@@ -5322,7 +5323,7 @@ move_stmt_op (tree *tp, int *walk_subtre
statement. */
static tree
-move_stmt_r (gimple_stmt_iterator *gsi_p, bool *walk_subtrees,
+move_stmt_r (gimple_stmt_iterator *gsi_p, bool *handled_ops_p,
struct walk_stmt_info *wi)
{
struct move_stmt_d *p = (struct move_stmt_d *) wi->info;
@@ -5341,7 +5342,7 @@ move_stmt_r (gimple_stmt_iterator *gsi_p
function. */
bool save_remap_decls_p = p->remap_decls_p;
p->remap_decls_p = false;
- *walk_subtrees = 0;
+ *handled_ops_p = true;
walk_gimple_seq (gimple_omp_body (stmt), move_stmt_r, move_stmt_op, wi);
More information about the Gcc-patches
mailing list