This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
+ if (gfc_is_do_var (expr->symtree->n.sym) + && !expr->symtree->n.sym->attr.target) + { + se->want_pointer = 0; + gfc_conv_expr (se, expr); + var = gfc_create_var (TREE_TYPE (se->expr), "arg"); + gfc_add_modify (&se->pre, var, se->expr); + se->expr = gfc_build_addr_expr (NULL_TREE, var); + gcc_assert (!se->post.head); + return; +
This appears to create an arg variable for each instance of the do variable being passed to a call. That would be wasteful in terms of stack usage.
Better would be to create exactly one arg variable per do variable that needs copying. And further, for those arg variables to be properly scoped inside the loop, so that arg variables from different loop nests can share stack space (see partition_stack_vars).
Further, since it's illegal for the called function to modify the loop variable, it ought to be illegal for it to modify the stack copy of the loop variable. Thus it should be possible to write to the copy exactly once, at the beginning of the loop iteration. Ideally the store would be positioned at the nearest block that dominates all of the uses, but that's obviously hard to do from the front end, and I don't recall that the the optimizers are set up to sink a memory store in that direction.
Cheers, - Tobi
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |