sra: Cap number of sub-access propagations with a param (PR 93435)
authorMartin Jambor <mjambor@suse.cz>
Fri, 20 Mar 2020 23:21:02 +0000 (00:21 +0100)
committerMartin Jambor <mjambor@suse.cz>
Fri, 20 Mar 2020 23:21:02 +0000 (00:21 +0100)
commit29f23ed79b60949fc60f6fdbbd931bd58090b241
tree2d50bd30c920febc2b540dfca18e3dbce4189055
parentcc3afc9db0710fe40e3d9a5e941e5e4efe7227f2
sra: Cap number of sub-access propagations with a param (PR 93435)

PR 93435 is a perfect SRA bomb.  It initializes an array of 16 chars
element-wise, then uses that to initialize an aggregate that consists
of four such arrays, that one to initialize one four times as big as
the previous one all the way to an aggregate that has 64kb.

This causes the sub-access propagation across assignments to create
thousands of byte-sized artificial accesses which are then eligible to
be replaced - they do facilitate forward propagation but there is
enough of them for DSE to never finish.

This patch avoids that situation by accounting how many of such
replacements can be created per SRA candidate.  The default value of
32 was just the largest power of two that did not slow down
compilation of the testcase, but it should also hopefully be big
enough for any reasonable input that might rely on the optimization.

2020-03-20  Martin Jambor  <mjambor@suse.cz>

PR tree-optimization/93435
* params.opt (sra-max-propagations): New parameter.
* tree-sra.c (propagation_budget): New variable.
(budget_for_propagation_access): New function.
(propagate_subaccesses_from_rhs): Use it.
(propagate_subaccesses_from_lhs): Likewise.
(propagate_all_subaccesses): Set up and destroy propagation_budget.

gcc/testsuite/
* gcc.dg/tree-ssa/pr93435.c: New test.
gcc/ChangeLog
gcc/params.opt
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/pr93435.c [new file with mode: 0644]
gcc/tree-sra.c