Improvements to code hoisting
Maxim Kuvyrkov
maxim@codesourcery.com
Wed Jun 16 15:57:00 GMT 2010
The following series of patches improves code hoisting and PRE RTL-level
optimizations. The two threads of the patches correspond to
target-independent changes to gcse.c and to changes to ARM backend to
make it emit RTL that is better suited for optimizers.
Motivating examples for this work are ARM PRs
http://gcc.gnu.org/PR42495
http://gcc.gnu.org/PR42574
With the patches applied GCC produces perfect code for these examples.
The general effect of the patches is that they allow more expressions to
be hoisted or PRE'd, thus making the optimizations more aggressive. The
negative effect of this are extended live ranges and increased register
pressure. Luckily, IRA and reload do good job in dealing with excessive
register pressure.
Still, while investigating size regressions I came upon a problem in
IRA's estimation of cost of putting a pseudo to memory when optimizing
for size. It appears that [ARM's] rtx_cost() model overestimates cost
of assigning a constant to memory, and, thus, makes IRA allocate a
register for something it shouldn't have. This results in a spill of
another variable that didn't get a register. I believe, this should not
block inclusion of the patches as they still provide significant
improvement on average.
The cumulative patch was tested on x86_64-linux-gnu (bootstrap, default
languages) and arm-linux-gnu (no bootstrap, c and c++ only).
There's a new FAIL on x86_64-linux-gnu gfortran testsuite: an ICE in
output_die, at dwarf2out.c:10875. Although I didn't look in the details
of the problem, it seems to be a latent bug uncovered by the patches.
I benchmarked an earlier version of these patches on a Cortex-A9 board
and got 0.1-0.5% size decrease on SPEC2K at -Os for both thumb1 and
thumb2 modes when compiled with and without -fpic.
I'm now working on getting SPEC2K speed numbers. I will post detailed
benchmarking results before committing the patches that aren't obvious
improvements. I'll appreciate if someone posts benchmark numbers for
other architectures.
Each patch will be posted in a subthread.
Thank you,
--
Maxim Kuvyrkov
CodeSourcery
maxim@codesourcery.com
(650) 331-3385 x724
More information about the Gcc-patches
mailing list