This is the mail archive of the
mailing list for the GCC project.
Re: Eliminate write-only variables
- From: Sandra Loosemore <sandra at codesourcery dot com>
- To: Jan Hubicka <hubicka at ucw dot cz>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Jakub Jelinek <jakub at redhat dot com>
- Date: Mon, 19 May 2014 21:59:37 -0600
- Subject: Re: Eliminate write-only variables
- Authentication-results: sourceware.org; auth=none
- References: <20140516172559 dot GF20755 at kam dot mff dot cuni dot cz> <53791418 dot 3060501 at codesourcery dot com> <20140518205956 dot GG1828 at kam dot mff dot cuni dot cz> <53797044 dot 2050704 at codesourcery dot com>
On 05/18/2014 08:45 PM, Sandra Loosemore wrote:
On 05/18/2014 02:59 PM, Jan Hubicka wrote:
For cases like local-statics-7 your approach can be "saved" by adding
simple IPA analysis
to look for static vars that are used only by one function and keeping
your DSE code active
for them, so we can still get rid of this special case assignments
during late compilation.
I am however not quite convinced it is worth the effort - do you have
some real world
cases where it helps?
Um, the well-known benchmark. ;-)
I looked at the generated code for this benchmark and see that your
patch is indeed not getting rid of all the pointless static variables,
while ours is, so this is quite disappointing. I'm thinking now that we
will still need to retain our patch at least locally, although we'd
really like to get it on trunk if possible.
Here is another testcase vaguely based on the same kind of
signal-processing algorithm as the benchmark, but coded without
reference to it. I have arm-none-eabi builds around for both 4.9.0 with
our remove_local_statics patch applied, and trunk with your patch. With
-O2, our optimization produces 23 instructions and gets rid of all 3
statics, yours produces 33 and only gets rid of 1 of them.
Of course it's lame to use static variables in this way, but OTOH it's
lame if GCC can't recognize them and optimize them away, too.
fir (int *coeffs, int coeff_length, int *input, int input_length, int *output)
static int *coeffp;
static int *inputp;
static int *outputp;
int i, c, acc;
for (i = 0; i < input_length; i++)
coeffp = coeffs;
inputp = input + i;
outputp = output + i;
acc = 0;
for (c = 0; c < coeff_length; c++)
acc += *coeffp * *inputp;
*outputp = acc;