https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128846

--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to [email protected] from comment #8)
> >> This is the x86_64-linux -m64 behaviour.  For i686, I see this instead:
> >
> > I don't have convenient access to a bare i686, but using -march=i686
> 
> me neither.  This is always a 64-bit kernel either with a 32-bit gcc
> (Solaris) or 64-bit gcc -m32 (Linux).
> 
> > shows we don't vectorize on trunk, even with -fno-vect-cost-model,
> > so that would explain the lower alignment (it's the vectorizer requesting
> > a alrger alignment).  With -march=i686 -msse2 it gets vectorized and
> > alignment is sufficient.
> 
> Here's part of the difference:
> 
> * Linux defaults to -march=pentiumpro -mno-sse2
> 
> * Solaris defaults to -march=pentium4 -msse2
> 
>   With -mno-sse2 the test passes.
> 
> > So the solaris alignment should be sufficient for movaps %xmm, so how
> > is it not?
> 
> Alignment is correct in both cases:
> 
> * Linux/i386 pentium4:
> 
>   [18] .tbss
>        NOBITS          0804bef0 002ef0 000288 00   0   0 16
>        [00000403]: WRITE, ALLOC, TLS
> 
> * Solaris/i386 pentium4:
> 
>   [26] .tbss
>        NOBITS          08060ed0 000ed0 000288 00   0   0 16
>        [00000403]: WRITE, ALLOC, TLS
> 
> However, there are still codegen differences, as attached:
> 
> * Linux/i386 pentium4:
> 
> Breakpoint 1, 0x08049040 in main ()
> => 0x8049040 <main>:  mov    %gs:0x0,%edx
> => 0x8049047 <main+7>:        lea    -0x290(%edx),%eax

good

> (gdb) p/x $edx
> $10 = 0xf7c5a9c0
> => 0x804904d <main+13>:       add    $0xfffffff0,%edx
> (gdb) p/x $eax
> $11 = 0xf7c5a730
> => 0x8049053 <main+19>:       movapd 0x804a010,%xmm0
> => 0x804905b <main+27>:       lea    %cs:0x0(%esi,%eiz,1),%esi
> => 0x8049060 <main+32>:       movapd %xmm0,(%eax)
> 
> * Solaris/i386 pentium4:
> 
> Thread 2 hit Breakpoint 1, 0x08050c30 in main ()
> => 0x8050c30 <main>:  mov    %gs:0x0,%ecx
> => 0x8050c37 <main+7>:        movsd  0x8050a00,%xmm0
> (gdb) p/x $ecx
> $6 = 0xfe5e04c0
> => 0x8050c3f <main+15>:       lea    -0x288(%ecx),%eax

vs. bad.  So the TLS base looks the same but somehow TLS
layout, while the base might be sufficiently aligned, is
not guaranteeing alignment of the TLS variable.  Maybe
a (dynamic) linker issue?

Does

__thread double thrtest[81] __attribute__((aligned(16)));

get properly aligned?  Maybe the size somehow confuses the
layout - guessing that [82] will work (it also works on Linux).

Reply via email to