This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/12105] Local Variabels on "Out-of-phase" Alignment on x86
- From: "dfoesch at cs dot nmsu dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 13 Sep 2003 00:13:09 -0000
- Subject: [Bug c/12105] Local Variabels on "Out-of-phase" Alignment on x86
- References: <20030829160604.12105.dfoesch@cs.nmsu.edu>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12105
------- Additional Comments From dfoesch at cs dot nmsu dot edu 2003-09-13 00:13 -------
Subject: Re: Local Variabels on "Out-of-phase" Alignment on x86
I fixed the problem, with -O3 optimization it was inlining my code.
gcc 3.2.1 by default already does what your assembly hack does.
That, and a shorter version of your assembly hack is:
andl $-16, %esp
Which is what gcc automatically places in code.
On Wednesday, Sep 10, 2003, at 08:07 America/Denver, steffen at boerm
dot net wrote:
> PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT*
> gcc-bugs@gcc.gnu.org.
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12105
>
>
>
> ------- Additional Comments From steffen at boerm dot net 2003-09-10
> 14:07 -------
> Subject: New: Local Variabels on "Out-of-phase" Alignment on x86
>
>
> Hi.
>
> I ran into the same problem when trying to use SSE in my programs. I
> fixed it by using an inline assembler hack:
>
> asm("movl %esp,%eax");
> asm("andl $15,%eax");
> asm("subl %esp,%eax");
>
> Putting this fragment at the beginning of main() makes sure that the
> stack pointer is correctly aligned for all functions called from
> main(),
> so all local variables are aligned properly and SSE works just fine.
>
> Of course, this is not the optimal way of doing it, just a
> quick'n'dirty
> workaround. Inlining, for example, will break it.
> Using "-fomit-frame-pointer" should break it also.
> I guess the safest way of using my hack would be to use an extremely
> short main() function that calls "fixedmain()" function that does the
> real work and is somehow protected against being inlined. As soon as
> fixedmain() is reached, all registers have the values they are supposed
> to have and inlining should work as usual.
>
> I guess that the best way of fixing this permanently would be to make
> sure that the startup code in some crt*.o file corrects the stack
> pointer before calling main(). Then all problems should disappear.
>
> Best regards,
> Steffen 8-)
>
>
>
>
>
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.
>