On Thu, Sep 13, 2012 at 3:11 PM, Eric Botcazou <[email protected]> wrote:
> Hi,
>
> the attached testcase triggers a memory exhaustion at -O2 during the cunrolli
> pass on the mainline and 4.7 branch. The problem is that the size estimates
> disregard induction variable computations on the ground that they will be
> folded later. But they aren't folded between the iterations of the loop so
> they can add up and exhaust the memory during SSA updating if stars are
> properly aligned.
>
> The patch is a somewhat simple-minded fix... Bootstrapped/regtested on
> x86_64-
> suse-linux. OK for mainline and 4.7 branch?
Indeed somewhat simple-minded - when originally fixing a similar testcase
(heh ...) I improved things by improving CFG cleanup to fold some more
conditions by looking at SSA defs, that improved things a lot. I also thought
the real fix should involve some scalar optimization on a sub-range of the CFG.
That should be easiest when performing the copy in the first place - after all
we keep copy tables and such for the purpose of update-SSA so we might as
well create a lattice from PHI nodes we disassemble for use by copy_bb ...
On the patch itself - can you call the simple CCP before we call
cleanup_tree_cfg () please? We might get rid of that weirdo SSA lookup
there again then:
static bool
cleanup_control_expr_graph (basic_block bb, gimple_stmt_iterator gsi)
{
...
/* For conditions try harder and lookup single-argument
PHI nodes. Only do so from the same basic-block though
as other basic-blocks may be dead already. */
if (TREE_CODE (lhs) == SSA_NAME
&& !name_registered_for_update_p (lhs))
...
+ FOR_EACH_IMM_USE_ON_STMT (use, iter)
+ propagate_value (use, gimple_assign_rhs1 (stmt));
+
+ fold_stmt_inplace (&use_stmt_gsi);
+ update_stmt (use_stmt);
Use SET_USE (use, rhs1) and cache gimple_assign_rhs1 somewhere.
if (fold_stmt_inplace (&use_stmt_gsi))
update_stmt (use_stmt);
Thanks,
Richard.
>
> 2012-09-13 Eric Botcazou <[email protected]>
>
> * tree-ssa-loop-ivcanon.c (propagate_constants_for_unrolling): New.
> (tree_unroll_loops_completely): Starting from the second iteration,
> propagate constants within the innermost loops.
>
>
> 2012-09-13 Eric Botcazou <[email protected]>
>
> * gnat.dg/loop_optimization12.ad[sb]: New test.
>
>
> --
> Eric Botcazou