This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: RFA: New optimization: Convert local statics into non-statics
On Tue, Jul 15, 2008 at 10:05:00AM -0700, Chris Lattner wrote:
> On Jul 15, 2008, at 6:42 AM, Michael Meissner wrote:
>>> Regarding the usefulness of the pass. It's really not very useful in
>>> general, it is a benchmark-specific optimization. I don't think
>>> there
>>> is "real" code out there that can benefit from this. But the pass is
>>> very simplistic, so if someone volunteers to maintain it I guess I
>>> don't have any problem enabling it with some -f switch.
>>
>> Ah yes, the EEMBC benchmarks. If memory serves, it is the automotive
>> benchmarks that have code like:
>>
>> void foo(int n)
>> {
>> static int i;
>>
>> for (i = 0; i < n; i++)
>> something();
>> }
>
> This is a great example of a case that would be invalid to transform.
> "something" can call "foo", which could change 'i'.
No it can't, since the scope of i is limited to foo, and its address is not
taken so it escapes outside of the function. If i had global scope then yes,
the transformation should not be done. If I recall the original benchmark, it
may actually be a leaf function.
--
Michael Meissner
email: gnu@the-meissners.org
http://www.the-meissners.org