This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Optimize initialization from compound literals (PR tree-optimization/33723)
On 10/29/07, Richard Guenther <richard.guenther@gmail.com> wrote:
> On 10/29/07, Jakub Jelinek <jakub@redhat.com> wrote:
> > Hi!
> >
> > If the address of an compound literal is never taken and it is only
> > used as initializer to some variable, I believe a conforming program
> > can't find out whether we are first initializing some anonymous variable
> > and then copying that anonymous variable to the user var, or initializing
> > that user var directly. When SRA is not able to scalarize it (as shown
> > by the testcase which is modelled from using e.g.
> > mutex = (pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER;
> > condvar = (pthread_cond_t) PTHREAD_COND_INITIALIZER;
> > or
> > rwlock = (pthread_rwlock_t) PTHREAD_RWLOCK_INITIALIZER;
> > with glibc), this then survives until assembly.
> > The following patch optimizes this by initializing the variable to
> > the initializer of the compound literal if it's address has never been
> > taken. The generated assembly looks much better on x86_64-linux.
> >
> > Bootstrapped/regtested on x86_64-linux, ok for trunk?
>
> This is ok.
It looks like the test fails for at least -m32 on x86_64 as the
initializers are not
removed:
baz3 ()
{
union T t;
t = {};
t.f.f1 = 1;
t.f.f2 = 2;
t.f.f3 = 3;
t.f.f4 = 4;
t.f.f5 = 5;
t.f.f6 = 6;
t.f.f7 = 7;
t.f.f8 = 8;
t.f.f9 = 9;
t.f.f10 = 10;
t.f.f11 = 11;
test (&t);
}
Can you please investigate?
Thanks,
Richard.