Subject: RE: g++ 3.4.0 cygwin, codegen SSE & alignement issues
From: "Dave Korn" <[email-masked]>
To: <[email-masked]>
Cc: <[email-masked]>
Date: Wed, 28 Apr 2004 16:51:55 +0100

> -----Original Message-----
> From: cygwin-owner On Behalf Of tbp
> Sent: 28 April 2004 16:16

[  Now x-posted to gcc list, since it's seemingly a gcc issue rather than a
cygwin environment issue.  You might also care to refer to the current
discussion on the gcc-patches mailing list under the thread 

"Re: [Bug target/15106] Vector varargs failure for AltiVec on ppc32 linux"

which is discussing the same problem arising on ppc targets.  ]

> > It's an ABI incompatiblity issue, GCC expects a 16-byte 
> aligned stack,
> > but the Windows ABI, to the extent one actually exists, only assumes
> > a 4-byte aligned stack (and even that's not a strict requirement).
> Is there an official or semi official way to fix it or do i have to 
> insert something like "mov esp, eax; and 0x15, eax; sub eax, 
> esp" where 
> it helps?

  I'd recommend doing that in the startup code in gcc's crt0.s myself.  The
real question is, is the compiler generating code that guarantees the stack
stays aligned, so you can do that just once at startup?  It certainly ought
to.

> I understand -mfpmath=sse is flagged as experimental. What i 
> don't get 
> is why the compiler emits totally bogus code when using default 
> switches: -O3 -march=k8 -> boom. -O3 -march=pentium4 -> boom.

  The division of responsibility between OS, CRT/startup and compiler leaves
it unclear as to who is supposed to ensure the alignment of the stack.  IMO,
it's a compiler's problem to see to it that if the stack starts off aligned
it remains that way, by always generating stack frames that are a multiple
of the alignment requirement, and it's the CRT/startup code that is
responsible for mediating between what the compiled code requires and what
the underlying OS/arch provides for stack pointer alignment at startup.  Of
course, that's IMO, and my opinion is hardly definitive.

    cheers, 
      DaveK
-- 
Can't think of a witty .sigline today....

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/