frontend_passes (expr_array): Replace by vec template.
2014-08-26 Thomas Koenig <tkoenig@gcc.gnu.org> * frontend_passes (expr_array): Replace by vec template. (expr_size): Remove. (expr_count): Remove. (doloop_list): Replace by vec template. (doloop_size): Remove. (gfc_run_passes): Adjust to use of vec template. (cfe_register_funcs): Likewise. (cfe_expr_0): Likewise. (doloop_code): Likewise. From-SVN: r214532
This commit is contained in:
parent
dd60a84ce0
commit
6c7069d663
|
@ -1,3 +1,15 @@
|
||||||
|
2014-08-26 Thomas Koenig <tkoenig@gcc.gnu.org>
|
||||||
|
|
||||||
|
* frontend_passes (expr_array): Replace by vec template.
|
||||||
|
(expr_size): Remove.
|
||||||
|
(expr_count): Remove.
|
||||||
|
(doloop_list): Replace by vec template.
|
||||||
|
(doloop_size): Remove.
|
||||||
|
(gfc_run_passes): Adjust to use of vec template.
|
||||||
|
(cfe_register_funcs): Likewise.
|
||||||
|
(cfe_expr_0): Likewise.
|
||||||
|
(doloop_code): Likewise.
|
||||||
|
|
||||||
2014-08-22 Steven Bosscher <steven@gcc.gnu.org>
|
2014-08-22 Steven Bosscher <steven@gcc.gnu.org>
|
||||||
|
|
||||||
PR fortran/62135
|
PR fortran/62135
|
||||||
|
|
|
@ -47,11 +47,9 @@ static int callback_reduction (gfc_expr **, int *, void *);
|
||||||
|
|
||||||
static int count_arglist;
|
static int count_arglist;
|
||||||
|
|
||||||
/* Pointer to an array of gfc_expr ** we operate on, plus its size
|
/* Vector of gfc_expr ** we operate on. */
|
||||||
and counter. */
|
|
||||||
|
|
||||||
static gfc_expr ***expr_array;
|
static vec<gfc_expr **> expr_array;
|
||||||
static int expr_size, expr_count;
|
|
||||||
|
|
||||||
/* Pointer to the gfc_code we currently work on - to be able to insert
|
/* Pointer to the gfc_code we currently work on - to be able to insert
|
||||||
a block before the statement. */
|
a block before the statement. */
|
||||||
|
@ -81,8 +79,9 @@ static int iterator_level;
|
||||||
|
|
||||||
/* Keep track of DO loop levels. */
|
/* Keep track of DO loop levels. */
|
||||||
|
|
||||||
static gfc_code **doloop_list;
|
static vec<gfc_code *> doloop_list;
|
||||||
static int doloop_size, doloop_level;
|
|
||||||
|
static int doloop_level;
|
||||||
|
|
||||||
/* Vector of gfc_expr * to keep track of DO loops. */
|
/* Vector of gfc_expr * to keep track of DO loops. */
|
||||||
|
|
||||||
|
@ -101,23 +100,18 @@ gfc_run_passes (gfc_namespace *ns)
|
||||||
/* Warn about dubious DO loops where the index might
|
/* Warn about dubious DO loops where the index might
|
||||||
change. */
|
change. */
|
||||||
|
|
||||||
doloop_size = 20;
|
|
||||||
doloop_level = 0;
|
doloop_level = 0;
|
||||||
doloop_list = XNEWVEC(gfc_code *, doloop_size);
|
|
||||||
doloop_warn (ns);
|
doloop_warn (ns);
|
||||||
XDELETEVEC (doloop_list);
|
doloop_list.release ();
|
||||||
|
|
||||||
if (gfc_option.flag_frontend_optimize)
|
if (gfc_option.flag_frontend_optimize)
|
||||||
{
|
{
|
||||||
expr_size = 20;
|
|
||||||
expr_array = XNEWVEC(gfc_expr **, expr_size);
|
|
||||||
|
|
||||||
optimize_namespace (ns);
|
optimize_namespace (ns);
|
||||||
optimize_reduction (ns);
|
optimize_reduction (ns);
|
||||||
if (gfc_option.dump_fortran_optimized)
|
if (gfc_option.dump_fortran_optimized)
|
||||||
gfc_dump_parse_tree (ns, stdout);
|
gfc_dump_parse_tree (ns, stdout);
|
||||||
|
|
||||||
XDELETEVEC (expr_array);
|
expr_array.release ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -420,13 +414,7 @@ cfe_register_funcs (gfc_expr **e, int *walk_subtrees ATTRIBUTE_UNUSED,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (expr_count >= expr_size)
|
expr_array.safe_push (e);
|
||||||
{
|
|
||||||
expr_size += expr_size;
|
|
||||||
expr_array = XRESIZEVEC(gfc_expr **, expr_array, expr_size);
|
|
||||||
}
|
|
||||||
expr_array[expr_count] = e;
|
|
||||||
expr_count ++;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -599,6 +587,7 @@ cfe_expr_0 (gfc_expr **e, int *walk_subtrees,
|
||||||
{
|
{
|
||||||
int i,j;
|
int i,j;
|
||||||
gfc_expr *newvar;
|
gfc_expr *newvar;
|
||||||
|
gfc_expr **ei, **ej;
|
||||||
|
|
||||||
/* Don't do this optimization within OMP workshare. */
|
/* Don't do this optimization within OMP workshare. */
|
||||||
|
|
||||||
|
@ -608,36 +597,36 @@ cfe_expr_0 (gfc_expr **e, int *walk_subtrees,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_count = 0;
|
expr_array.release ();
|
||||||
|
|
||||||
gfc_expr_walker (e, cfe_register_funcs, NULL);
|
gfc_expr_walker (e, cfe_register_funcs, NULL);
|
||||||
|
|
||||||
/* Walk through all the functions. */
|
/* Walk through all the functions. */
|
||||||
|
|
||||||
for (i=1; i<expr_count; i++)
|
FOR_EACH_VEC_ELT_FROM (expr_array, i, ei, 1)
|
||||||
{
|
{
|
||||||
/* Skip if the function has been replaced by a variable already. */
|
/* Skip if the function has been replaced by a variable already. */
|
||||||
if ((*(expr_array[i]))->expr_type == EXPR_VARIABLE)
|
if ((*ei)->expr_type == EXPR_VARIABLE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
newvar = NULL;
|
newvar = NULL;
|
||||||
for (j=0; j<i; j++)
|
for (j=0; j<i; j++)
|
||||||
{
|
{
|
||||||
if (gfc_dep_compare_functions (*(expr_array[i]),
|
ej = expr_array[j];
|
||||||
*(expr_array[j]), true) == 0)
|
if (gfc_dep_compare_functions (*ei, *ej, true) == 0)
|
||||||
{
|
{
|
||||||
if (newvar == NULL)
|
if (newvar == NULL)
|
||||||
newvar = create_var (*(expr_array[i]));
|
newvar = create_var (*ei);
|
||||||
|
|
||||||
if (gfc_option.warn_function_elimination)
|
if (gfc_option.warn_function_elimination)
|
||||||
warn_function_elimination (*(expr_array[j]));
|
warn_function_elimination (*ej);
|
||||||
|
|
||||||
free (*(expr_array[j]));
|
free (*ej);
|
||||||
*(expr_array[j]) = gfc_copy_expr (newvar);
|
*ej = gfc_copy_expr (newvar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (newvar)
|
if (newvar)
|
||||||
*(expr_array[i]) = newvar;
|
*ei = newvar;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We did all the necessary walking in this function. */
|
/* We did all the necessary walking in this function. */
|
||||||
|
@ -1671,25 +1660,23 @@ doloop_code (gfc_code **c, int *walk_subtrees ATTRIBUTE_UNUSED,
|
||||||
int i;
|
int i;
|
||||||
gfc_formal_arglist *f;
|
gfc_formal_arglist *f;
|
||||||
gfc_actual_arglist *a;
|
gfc_actual_arglist *a;
|
||||||
|
gfc_code *cl;
|
||||||
|
|
||||||
co = *c;
|
co = *c;
|
||||||
|
|
||||||
|
/* If the doloop_list grew, we have to truncate it here. */
|
||||||
|
|
||||||
|
if ((unsigned) doloop_level < doloop_list.length())
|
||||||
|
doloop_list.truncate (doloop_level);
|
||||||
|
|
||||||
switch (co->op)
|
switch (co->op)
|
||||||
{
|
{
|
||||||
case EXEC_DO:
|
case EXEC_DO:
|
||||||
|
|
||||||
/* Grow the temporary storage if necessary. */
|
|
||||||
if (doloop_level >= doloop_size)
|
|
||||||
{
|
|
||||||
doloop_size = 2 * doloop_size;
|
|
||||||
doloop_list = XRESIZEVEC (gfc_code *, doloop_list, doloop_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Mark the DO loop variable if there is one. */
|
|
||||||
if (co->ext.iterator && co->ext.iterator->var)
|
if (co->ext.iterator && co->ext.iterator->var)
|
||||||
doloop_list[doloop_level] = co;
|
doloop_list.safe_push (co);
|
||||||
else
|
else
|
||||||
doloop_list[doloop_level] = NULL;
|
doloop_list.safe_push ((gfc_code *) NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EXEC_CALL:
|
case EXEC_CALL:
|
||||||
|
@ -1708,14 +1695,14 @@ doloop_code (gfc_code **c, int *walk_subtrees ATTRIBUTE_UNUSED,
|
||||||
|
|
||||||
while (a && f)
|
while (a && f)
|
||||||
{
|
{
|
||||||
for (i=0; i<doloop_level; i++)
|
FOR_EACH_VEC_ELT (doloop_list, i, cl)
|
||||||
{
|
{
|
||||||
gfc_symbol *do_sym;
|
gfc_symbol *do_sym;
|
||||||
|
|
||||||
if (doloop_list[i] == NULL)
|
if (cl == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
do_sym = doloop_list[i]->ext.iterator->var->symtree->n.sym;
|
do_sym = cl->ext.iterator->var->symtree->n.sym;
|
||||||
|
|
||||||
if (a->expr && a->expr->symtree
|
if (a->expr && a->expr->symtree
|
||||||
&& a->expr->symtree->n.sym == do_sym)
|
&& a->expr->symtree->n.sym == do_sym)
|
||||||
|
@ -1755,6 +1742,7 @@ do_function (gfc_expr **e, int *walk_subtrees ATTRIBUTE_UNUSED,
|
||||||
gfc_formal_arglist *f;
|
gfc_formal_arglist *f;
|
||||||
gfc_actual_arglist *a;
|
gfc_actual_arglist *a;
|
||||||
gfc_expr *expr;
|
gfc_expr *expr;
|
||||||
|
gfc_code *dl;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
expr = *e;
|
expr = *e;
|
||||||
|
@ -1777,15 +1765,14 @@ do_function (gfc_expr **e, int *walk_subtrees ATTRIBUTE_UNUSED,
|
||||||
|
|
||||||
while (a && f)
|
while (a && f)
|
||||||
{
|
{
|
||||||
for (i=0; i<doloop_level; i++)
|
FOR_EACH_VEC_ELT (doloop_list, i, dl)
|
||||||
{
|
{
|
||||||
gfc_symbol *do_sym;
|
gfc_symbol *do_sym;
|
||||||
|
|
||||||
|
if (dl == NULL)
|
||||||
if (doloop_list[i] == NULL)
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
do_sym = doloop_list[i]->ext.iterator->var->symtree->n.sym;
|
do_sym = dl->ext.iterator->var->symtree->n.sym;
|
||||||
|
|
||||||
if (a->expr && a->expr->symtree
|
if (a->expr && a->expr->symtree
|
||||||
&& a->expr->symtree->n.sym == do_sym)
|
&& a->expr->symtree->n.sym == do_sym)
|
||||||
|
|
Loading…
Reference in New Issue