Commit 917948d3 by Zdenek Dvorak Committed by Zdenek Dvorak

cgraphbuild.c (rebuild_cgraph_edges): Export.

	* cgraphbuild.c (rebuild_cgraph_edges): Export.
	* cgraph.h (rebuild_cgraph_edges): Declare.
	* tree-pass.h (pass_expand_omp_ssa): New.
	* omp-low.c (find_omp_clause): Export.
	(copy_var_decl): Split from omp_copy_decl_2.
	(build_omp_barrier): Return the call to emit instead of emitting
	it directly.
	(lower_rec_input_clauses, expand_omp_single): Gimplify the result of
	build_omp_barrier.
	(extract_omp_for_data, expand_parallel_call, expand_omp_parallel,
	expand_omp_for_generic, expand_omp_for_static_nochunk,
	expand_omp_for_static_chunk, expand_omp_for, expand_omp_sections):
	Adapted to work on SSA form.
	(execute_expand_omp): Do not invalidate dominance information.
	(gate_expand_omp): Do not run with -fopenmp-ssa flag.
	(gate_expand_omp_ssa, pass_expand_omp_ssa): New.
	* gimplify.c (gimplify_omp_for): Ensure that the control variable is
	a gimple_reg.
	(force_gimple_operand): Allow gimplifying code expressions without
	value.
	* tree-predcom.c (mark_virtual_ops_for_renaming): Handle phi nodes.
	* common.opt (fopenmp-ssa): New.
	* tree-flow.h (find_omp_clause, copy_var_decl): Declare.
	* Makefile.in (tree-cfg.o): Add TREE_INLINE_H dependency.
	* tree-cfg.c: Include tree-inline.h.
	(struct move_stmt_d): Replace vars_to_remove by vars_map field.
	(replace_by_duplicate_decl, replace_ssa_name,
	mark_virtual_ops_in_region): New functions.
	(move_stmt_r, move_block_to_fn, move_sese_region_to_fn): Adapted
	to work on SSA form.
	* passes.c (init_optimization_passes): Add pass_expand_omp_ssa pass.
	* tree-ssa-operands.c (get_expr_operands): Handle operands of OMP
	constructs.

From-SVN: r128223
parent e054e6fb
2007-09-06 Zdenek Dvorak <ook@ucw.cz>
* cgraphbuild.c (rebuild_cgraph_edges): Export.
* cgraph.h (rebuild_cgraph_edges): Declare.
* tree-pass.h (pass_expand_omp_ssa): New.
* omp-low.c (find_omp_clause): Export.
(copy_var_decl): Split from omp_copy_decl_2.
(build_omp_barrier): Return the call to emit instead of emitting
it directly.
(lower_rec_input_clauses, expand_omp_single): Gimplify the result of
build_omp_barrier.
(extract_omp_for_data, expand_parallel_call, expand_omp_parallel,
expand_omp_for_generic, expand_omp_for_static_nochunk,
expand_omp_for_static_chunk, expand_omp_for, expand_omp_sections):
Adapted to work on SSA form.
(execute_expand_omp): Do not invalidate dominance information.
(gate_expand_omp): Do not run with -fopenmp-ssa flag.
(gate_expand_omp_ssa, pass_expand_omp_ssa): New.
* gimplify.c (gimplify_omp_for): Ensure that the control variable is
a gimple_reg.
(force_gimple_operand): Allow gimplifying code expressions without
value.
* tree-predcom.c (mark_virtual_ops_for_renaming): Handle phi nodes.
* common.opt (fopenmp-ssa): New.
* tree-flow.h (find_omp_clause, copy_var_decl): Declare.
* Makefile.in (tree-cfg.o): Add TREE_INLINE_H dependency.
* tree-cfg.c: Include tree-inline.h.
(struct move_stmt_d): Replace vars_to_remove by vars_map field.
(replace_by_duplicate_decl, replace_ssa_name,
mark_virtual_ops_in_region): New functions.
(move_stmt_r, move_block_to_fn, move_sese_region_to_fn): Adapted
to work on SSA form.
* passes.c (init_optimization_passes): Add pass_expand_omp_ssa pass.
* tree-ssa-operands.c (get_expr_operands): Handle operands of OMP
constructs.
2007-09-06 Laurynas Biveinis <laurynas.biveinis@gmail.com> 2007-09-06 Laurynas Biveinis <laurynas.biveinis@gmail.com>
* tree-loop-linear.c: Include obstack.h. * tree-loop-linear.c: Include obstack.h.
...@@ -2079,7 +2079,7 @@ tree-cfg.o : tree-cfg.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \ ...@@ -2079,7 +2079,7 @@ tree-cfg.o : tree-cfg.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \
$(DIAGNOSTIC_H) $(FUNCTION_H) $(TIMEVAR_H) $(TM_H) coretypes.h \ $(DIAGNOSTIC_H) $(FUNCTION_H) $(TIMEVAR_H) $(TM_H) coretypes.h \
$(TREE_DUMP_H) except.h langhooks.h $(CFGLOOP_H) tree-pass.h \ $(TREE_DUMP_H) except.h langhooks.h $(CFGLOOP_H) tree-pass.h \
$(CFGLAYOUT_H) $(BASIC_BLOCK_H) hard-reg-set.h toplev.h \ $(CFGLAYOUT_H) $(BASIC_BLOCK_H) hard-reg-set.h toplev.h \
tree-ssa-propagate.h tree-ssa-propagate.h $(TREE_INLINE_H)
tree-cfgcleanup.o : tree-cfgcleanup.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \ tree-cfgcleanup.o : tree-cfgcleanup.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \
$(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) $(GGC_H) $(FLAGS_H) output.h \ $(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) $(GGC_H) $(FLAGS_H) output.h \
$(DIAGNOSTIC_H) toplev.h $(FUNCTION_H) $(TIMEVAR_H) $(TM_H) coretypes.h \ $(DIAGNOSTIC_H) toplev.h $(FUNCTION_H) $(TIMEVAR_H) $(TM_H) coretypes.h \
......
...@@ -344,6 +344,9 @@ struct cgraph_node *save_inline_function_body (struct cgraph_node *); ...@@ -344,6 +344,9 @@ struct cgraph_node *save_inline_function_body (struct cgraph_node *);
void record_references_in_initializer (tree); void record_references_in_initializer (tree);
bool cgraph_process_new_functions (void); bool cgraph_process_new_functions (void);
/* In cgraphbuild.c */
unsigned int rebuild_cgraph_edges (void);
/* In ipa.c */ /* In ipa.c */
bool cgraph_remove_unreachable_nodes (bool, FILE *); bool cgraph_remove_unreachable_nodes (bool, FILE *);
int cgraph_postorder (struct cgraph_node **); int cgraph_postorder (struct cgraph_node **);
......
...@@ -202,7 +202,7 @@ record_references_in_initializer (tree decl) ...@@ -202,7 +202,7 @@ record_references_in_initializer (tree decl)
/* Rebuild cgraph edges for current function node. This needs to be run after /* Rebuild cgraph edges for current function node. This needs to be run after
passes that don't update the cgraph. */ passes that don't update the cgraph. */
static unsigned int unsigned int
rebuild_cgraph_edges (void) rebuild_cgraph_edges (void)
{ {
basic_block bb; basic_block bb;
......
...@@ -709,6 +709,10 @@ fomit-frame-pointer ...@@ -709,6 +709,10 @@ fomit-frame-pointer
Common Report Var(flag_omit_frame_pointer) Optimization Common Report Var(flag_omit_frame_pointer) Optimization
When possible do not generate stack frames When possible do not generate stack frames
fopenmp-ssa
Common Report Var(flag_openmp_ssa)
Expand OpenMP operations on SSA form
foptimize-register-move foptimize-register-move
Common Report Var(flag_regmove) Optimization Common Report Var(flag_regmove) Optimization
Do the full register move optimization pass Do the full register move optimization pass
......
...@@ -5114,8 +5114,9 @@ gimplify_omp_parallel (tree *expr_p, tree *pre_p) ...@@ -5114,8 +5114,9 @@ gimplify_omp_parallel (tree *expr_p, tree *pre_p)
static enum gimplify_status static enum gimplify_status
gimplify_omp_for (tree *expr_p, tree *pre_p) gimplify_omp_for (tree *expr_p, tree *pre_p)
{ {
tree for_stmt, decl, t; tree for_stmt, decl, var, t;
enum gimplify_status ret = GS_OK; enum gimplify_status ret = GS_OK;
tree body, init_decl = NULL_TREE;
for_stmt = *expr_p; for_stmt = *expr_p;
...@@ -5134,6 +5135,20 @@ gimplify_omp_for (tree *expr_p, tree *pre_p) ...@@ -5134,6 +5135,20 @@ gimplify_omp_for (tree *expr_p, tree *pre_p)
else else
omp_add_variable (gimplify_omp_ctxp, decl, GOVD_PRIVATE | GOVD_SEEN); omp_add_variable (gimplify_omp_ctxp, decl, GOVD_PRIVATE | GOVD_SEEN);
/* If DECL is not a gimple register, create a temporary variable to act as an
iteration counter. This is valid, since DECL cannot be modified in the
body of the loop. */
if (!is_gimple_reg (decl))
{
var = create_tmp_var (TREE_TYPE (decl), get_name (decl));
GENERIC_TREE_OPERAND (t, 0) = var;
init_decl = build_gimple_modify_stmt (decl, var);
omp_add_variable (gimplify_omp_ctxp, var, GOVD_PRIVATE | GOVD_SEEN);
}
else
var = decl;
ret |= gimplify_expr (&GENERIC_TREE_OPERAND (t, 1), ret |= gimplify_expr (&GENERIC_TREE_OPERAND (t, 1),
&OMP_FOR_PRE_BODY (for_stmt), &OMP_FOR_PRE_BODY (for_stmt),
NULL, is_gimple_val, fb_rvalue); NULL, is_gimple_val, fb_rvalue);
...@@ -5143,6 +5158,7 @@ gimplify_omp_for (tree *expr_p, tree *pre_p) ...@@ -5143,6 +5158,7 @@ gimplify_omp_for (tree *expr_p, tree *pre_p)
t = OMP_FOR_COND (for_stmt); t = OMP_FOR_COND (for_stmt);
gcc_assert (COMPARISON_CLASS_P (t)); gcc_assert (COMPARISON_CLASS_P (t));
gcc_assert (GENERIC_TREE_OPERAND (t, 0) == decl); gcc_assert (GENERIC_TREE_OPERAND (t, 0) == decl);
TREE_OPERAND (t, 0) = var;
ret |= gimplify_expr (&GENERIC_TREE_OPERAND (t, 1), ret |= gimplify_expr (&GENERIC_TREE_OPERAND (t, 1),
&OMP_FOR_PRE_BODY (for_stmt), &OMP_FOR_PRE_BODY (for_stmt),
...@@ -5155,21 +5171,23 @@ gimplify_omp_for (tree *expr_p, tree *pre_p) ...@@ -5155,21 +5171,23 @@ gimplify_omp_for (tree *expr_p, tree *pre_p)
case PREINCREMENT_EXPR: case PREINCREMENT_EXPR:
case POSTINCREMENT_EXPR: case POSTINCREMENT_EXPR:
t = build_int_cst (TREE_TYPE (decl), 1); t = build_int_cst (TREE_TYPE (decl), 1);
t = build2 (PLUS_EXPR, TREE_TYPE (decl), decl, t); t = build2 (PLUS_EXPR, TREE_TYPE (decl), var, t);
t = build_gimple_modify_stmt (decl, t); t = build_gimple_modify_stmt (var, t);
OMP_FOR_INCR (for_stmt) = t; OMP_FOR_INCR (for_stmt) = t;
break; break;
case PREDECREMENT_EXPR: case PREDECREMENT_EXPR:
case POSTDECREMENT_EXPR: case POSTDECREMENT_EXPR:
t = build_int_cst (TREE_TYPE (decl), -1); t = build_int_cst (TREE_TYPE (decl), -1);
t = build2 (PLUS_EXPR, TREE_TYPE (decl), decl, t); t = build2 (PLUS_EXPR, TREE_TYPE (decl), var, t);
t = build_gimple_modify_stmt (decl, t); t = build_gimple_modify_stmt (var, t);
OMP_FOR_INCR (for_stmt) = t; OMP_FOR_INCR (for_stmt) = t;
break; break;
case GIMPLE_MODIFY_STMT: case GIMPLE_MODIFY_STMT:
gcc_assert (GIMPLE_STMT_OPERAND (t, 0) == decl); gcc_assert (GIMPLE_STMT_OPERAND (t, 0) == decl);
GIMPLE_STMT_OPERAND (t, 0) = var;
t = GIMPLE_STMT_OPERAND (t, 1); t = GIMPLE_STMT_OPERAND (t, 1);
switch (TREE_CODE (t)) switch (TREE_CODE (t))
{ {
...@@ -5177,11 +5195,14 @@ gimplify_omp_for (tree *expr_p, tree *pre_p) ...@@ -5177,11 +5195,14 @@ gimplify_omp_for (tree *expr_p, tree *pre_p)
if (TREE_OPERAND (t, 1) == decl) if (TREE_OPERAND (t, 1) == decl)
{ {
TREE_OPERAND (t, 1) = TREE_OPERAND (t, 0); TREE_OPERAND (t, 1) = TREE_OPERAND (t, 0);
TREE_OPERAND (t, 0) = decl; TREE_OPERAND (t, 0) = var;
break; break;
} }
/* Fallthru. */
case MINUS_EXPR: case MINUS_EXPR:
gcc_assert (TREE_OPERAND (t, 0) == decl); gcc_assert (TREE_OPERAND (t, 0) == decl);
TREE_OPERAND (t, 0) = var;
break; break;
default: default:
gcc_unreachable (); gcc_unreachable ();
...@@ -5195,7 +5216,13 @@ gimplify_omp_for (tree *expr_p, tree *pre_p) ...@@ -5195,7 +5216,13 @@ gimplify_omp_for (tree *expr_p, tree *pre_p)
gcc_unreachable (); gcc_unreachable ();
} }
gimplify_to_stmt_list (&OMP_FOR_BODY (for_stmt)); body = OMP_FOR_BODY (for_stmt);
gimplify_to_stmt_list (&body);
t = alloc_stmt_list ();
if (init_decl)
append_to_statement_list (init_decl, &t);
append_to_statement_list (body, &t);
OMP_FOR_BODY (for_stmt) = t;
gimplify_adjust_omp_clauses (&OMP_FOR_CLAUSES (for_stmt)); gimplify_adjust_omp_clauses (&OMP_FOR_CLAUSES (for_stmt));
return ret == GS_ALL_DONE ? GS_ALL_DONE : GS_ERROR; return ret == GS_ALL_DONE ? GS_ALL_DONE : GS_ERROR;
...@@ -6591,9 +6618,18 @@ force_gimple_operand (tree expr, tree *stmts, bool simple, tree var) ...@@ -6591,9 +6618,18 @@ force_gimple_operand (tree expr, tree *stmts, bool simple, tree var)
if (var) if (var)
expr = build_gimple_modify_stmt (var, expr); expr = build_gimple_modify_stmt (var, expr);
ret = gimplify_expr (&expr, stmts, NULL, if (TREE_CODE (expr) != GIMPLE_MODIFY_STMT
gimple_test_f, fb_rvalue); && TREE_TYPE (expr) == void_type_node)
gcc_assert (ret != GS_ERROR); {
gimplify_and_add (expr, stmts);
expr = NULL_TREE;
}
else
{
ret = gimplify_expr (&expr, stmts, NULL,
gimple_test_f, fb_rvalue);
gcc_assert (ret != GS_ERROR);
}
if (gimple_referenced_vars (cfun)) if (gimple_referenced_vars (cfun))
{ {
......
...@@ -515,6 +515,7 @@ init_optimization_passes (void) ...@@ -515,6 +515,7 @@ init_optimization_passes (void)
NEXT_PASS (pass_referenced_vars); NEXT_PASS (pass_referenced_vars);
NEXT_PASS (pass_reset_cc_flags); NEXT_PASS (pass_reset_cc_flags);
NEXT_PASS (pass_build_ssa); NEXT_PASS (pass_build_ssa);
NEXT_PASS (pass_expand_omp_ssa);
NEXT_PASS (pass_early_warn_uninitialized); NEXT_PASS (pass_early_warn_uninitialized);
NEXT_PASS (pass_rebuild_cgraph_edges); NEXT_PASS (pass_rebuild_cgraph_edges);
NEXT_PASS (pass_early_inline); NEXT_PASS (pass_early_inline);
......
...@@ -711,6 +711,8 @@ extern struct omp_region *root_omp_region; ...@@ -711,6 +711,8 @@ extern struct omp_region *root_omp_region;
extern struct omp_region *new_omp_region (basic_block, enum tree_code, extern struct omp_region *new_omp_region (basic_block, enum tree_code,
struct omp_region *); struct omp_region *);
extern void free_omp_regions (void); extern void free_omp_regions (void);
extern tree find_omp_clause (tree, enum tree_code);
tree copy_var_decl (tree, tree, tree);
/*--------------------------------------------------------------------------- /*---------------------------------------------------------------------------
Function prototypes Function prototypes
......
...@@ -290,6 +290,7 @@ extern struct tree_opt_pass pass_lower_vector; ...@@ -290,6 +290,7 @@ extern struct tree_opt_pass pass_lower_vector;
extern struct tree_opt_pass pass_lower_vector_ssa; extern struct tree_opt_pass pass_lower_vector_ssa;
extern struct tree_opt_pass pass_lower_omp; extern struct tree_opt_pass pass_lower_omp;
extern struct tree_opt_pass pass_expand_omp; extern struct tree_opt_pass pass_expand_omp;
extern struct tree_opt_pass pass_expand_omp_ssa;
extern struct tree_opt_pass pass_object_sizes; extern struct tree_opt_pass pass_object_sizes;
extern struct tree_opt_pass pass_fold_builtins; extern struct tree_opt_pass pass_fold_builtins;
extern struct tree_opt_pass pass_stdarg; extern struct tree_opt_pass pass_stdarg;
......
...@@ -1393,7 +1393,16 @@ mark_virtual_ops_for_renaming (tree stmt) ...@@ -1393,7 +1393,16 @@ mark_virtual_ops_for_renaming (tree stmt)
tree var; tree var;
if (TREE_CODE (stmt) == PHI_NODE) if (TREE_CODE (stmt) == PHI_NODE)
return; {
var = PHI_RESULT (stmt);
if (is_gimple_reg (var))
return;
if (TREE_CODE (var) == SSA_NAME)
var = SSA_NAME_VAR (var);
mark_sym_for_renaming (var);
return;
}
update_stmt (stmt); update_stmt (stmt);
......
...@@ -2247,21 +2247,72 @@ get_expr_operands (tree stmt, tree *expr_p, int flags) ...@@ -2247,21 +2247,72 @@ get_expr_operands (tree stmt, tree *expr_p, int flags)
get_expr_operands (stmt, &CHANGE_DYNAMIC_TYPE_LOCATION (expr), opf_use); get_expr_operands (stmt, &CHANGE_DYNAMIC_TYPE_LOCATION (expr), opf_use);
return; return;
case OMP_FOR:
{
tree init = OMP_FOR_INIT (expr);
tree cond = OMP_FOR_COND (expr);
tree incr = OMP_FOR_INCR (expr);
tree c, clauses = OMP_FOR_CLAUSES (stmt);
get_expr_operands (stmt, &GIMPLE_STMT_OPERAND (init, 0), opf_def);
get_expr_operands (stmt, &GIMPLE_STMT_OPERAND (init, 1), opf_use);
get_expr_operands (stmt, &TREE_OPERAND (cond, 1), opf_use);
get_expr_operands (stmt, &TREE_OPERAND (GIMPLE_STMT_OPERAND (incr, 1), 1),
opf_use);
c = find_omp_clause (clauses, OMP_CLAUSE_SCHEDULE);
if (c)
get_expr_operands (stmt, &OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (c),
opf_use);
return;
}
case OMP_CONTINUE:
{
get_expr_operands (stmt, &TREE_OPERAND (expr, 0), opf_def);
get_expr_operands (stmt, &TREE_OPERAND (expr, 1), opf_use);
return;
}
case OMP_PARALLEL:
{
tree c, clauses = OMP_PARALLEL_CLAUSES (stmt);
if (OMP_PARALLEL_DATA_ARG (stmt))
{
get_expr_operands (stmt, &OMP_PARALLEL_DATA_ARG (stmt), opf_use);
add_to_addressable_set (OMP_PARALLEL_DATA_ARG (stmt),
&s_ann->addresses_taken);
}
c = find_omp_clause (clauses, OMP_CLAUSE_IF);
if (c)
get_expr_operands (stmt, &OMP_CLAUSE_IF_EXPR (c), opf_use);
c = find_omp_clause (clauses, OMP_CLAUSE_NUM_THREADS);
if (c)
get_expr_operands (stmt, &OMP_CLAUSE_NUM_THREADS_EXPR (c), opf_use);
return;
}
case OMP_SECTIONS:
{
get_expr_operands (stmt, &OMP_SECTIONS_CONTROL (expr), opf_def);
return;
}
case BLOCK: case BLOCK:
case FUNCTION_DECL: case FUNCTION_DECL:
case EXC_PTR_EXPR: case EXC_PTR_EXPR:
case FILTER_EXPR: case FILTER_EXPR:
case LABEL_DECL: case LABEL_DECL:
case CONST_DECL: case CONST_DECL:
case OMP_PARALLEL:
case OMP_SECTIONS:
case OMP_FOR:
case OMP_SINGLE: case OMP_SINGLE:
case OMP_MASTER: case OMP_MASTER:
case OMP_ORDERED: case OMP_ORDERED:
case OMP_CRITICAL: case OMP_CRITICAL:
case OMP_RETURN: case OMP_RETURN:
case OMP_CONTINUE: case OMP_SECTION:
case OMP_SECTIONS_SWITCH:
/* Expressions that make no memory references. */ /* Expressions that make no memory references. */
return; return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment