public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* target/9290: incorrect alignment when using SSE on ia32
@ 2003-01-13 11:46 mark
  0 siblings, 0 replies; 3+ messages in thread
From: mark @ 2003-01-13 11:46 UTC (permalink / raw)
  To: gcc-gnats


>Number:         9290
>Category:       target
>Synopsis:       incorrect alignment when using SSE on ia32
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Mon Jan 13 03:46:02 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     mark@cal005304.student.utwente.nl
>Release:        3.3 20030106 (prerelease)
>Organization:
>Environment:
i686-pc-linux-gnu
>Description:
I have been testing the __builtin_ia32_ sse functions on the gcc-3.3
compiler. For the most part the results look promising, except the
alignment is incorrect. See the attached example, I've tried everything I
could think of to get the alignment working. Line "1f" in the disassembly
causes a segfault.

compiled with:
gcc -march=pentium3 -msse -O3 -c sse_bug.cpp -mpreferred-stack-boundary=4

gcc-version:
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3/specs
Configured with: ../gcc-20030106/configure
Thread model: posix
gcc version 3.3 20030106 (prerelease)

------ Source code --------------------------------------------------------
typedef int __m128 __attribute__ ((__mode__(__V4SF__)));

class sse_t {
        __m128 d __attribute__((aligned(16)));
public:
        sse_t();
        sse_t operator=(sse_t const &o) { d=o.d; }
};

class Contour { 
        sse_t test;
public:
        Contour();
}; 

Contour::Contour()
{
        sse_t z __attribute__ ((aligned(16)));

        test=z;
}

------ Resulting object code ------------------------------------------------
00000000 <_ZN7ContourC2Ev>:
   0:   55                      push   %ebp
   1:   89 e5                   mov    %esp,%ebp
   3:   83 ec 28                sub    $0x28,%esp
   6:   89 5d fc                mov    %ebx,0xfffffffc(%ebp)
   9:   8b 5d 08                mov    0x8(%ebp),%ebx
   c:   89 1c 24                mov    %ebx,(%esp,1)
   f:   e8 fc ff ff ff          call   10 <_ZN7ContourC2Ev+0x10>
  14:   8d 55 e8                lea    0xffffffe8(%ebp),%edx
  17:   89 14 24                mov    %edx,(%esp,1)
  1a:   e8 fc ff ff ff          call   1b <_ZN7ContourC2Ev+0x1b>
**1f:   0f 28 4d e8             movaps 0xffffffe8(%ebp),%xmm1   **
  23:   0f 29 0b                movaps %xmm1,(%ebx)
  26:   8b 5d fc                mov    0xfffffffc(%ebp),%ebx
  29:   89 ec                   mov    %ebp,%esp
  2b:   5d                      pop    %ebp
  2c:   c3                      ret    
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: target/9290: incorrect alignment when using SSE on ia32
@ 2003-01-13 13:46 m.j.s.vandoesburg
  0 siblings, 0 replies; 3+ messages in thread
From: m.j.s.vandoesburg @ 2003-01-13 13:46 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR target/9290; it has been noted by GNATS.

From: m.j.s.vandoesburg@planet.nl
To: tprince@computer.org, gcc-gnats@gcc.gnu.org
Cc:  
Subject: Re: target/9290: incorrect alignment when using SSE on ia32
Date: Mon, 13 Jan 2003 14:36:44 +0100

 	Don't data objects need to be allocated within a method which is
 	called from one which is built with -mpreferred-stack-alignment=4,
 	in order for gcc to apply alignment?
 
 The Contour object is not the problem, it's the temporary variable
 z. Obviously the given example is not realistic, but enough to provoke
 the bug. If I try to do a matrix multiplication with my own sse_t class
 there are temporaries created, these are not aligned.
 
 From what I understood (I can't remember where I found it, right now I'm
 doubting my own sanity) the new compiler aligns ebp to 16 bytes, and 16
 byte alignment for local variables should be possible (except in main
 unless you get the correct runtime environment).  I might be mistaken,
 in that case please consider it a feature request :-)


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: target/9290: incorrect alignment when using SSE on ia32
@ 2003-01-13 12:36 Tim Prince
  0 siblings, 0 replies; 3+ messages in thread
From: Tim Prince @ 2003-01-13 12:36 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR target/9290; it has been noted by GNATS.

From: Tim Prince <timothyprince@sbcglobal.net>
To: mark@cal005304.student.utwente.nl, gcc-gnats@gcc.gnu.org
Cc:  
Subject: Re: target/9290: incorrect alignment when using SSE on ia32
Date: Mon, 13 Jan 2003 04:33:43 -0800

 On Monday 13 January 2003 03:42, mark@cal005304.student.utwente.nl wrote:
 > >Number:         9290
 > >Category:       target
 > >Synopsis:       incorrect alignment when using SSE on ia32
 
 > I have been testing the __builtin_ia32_ sse functions on the gcc-3.3
 > compiler. For the most part the results look promising, except the
 > alignment is incorrect. See the attached example, I've tried everything I
 > could think of to get the alignment working. Line "1f" in the disassembly
 > causes a segfault.
 >
 > compiled with:
 > gcc -march=pentium3 -msse -O3 -c sse_bug.cpp -mpreferred-stack-boundary=4
 >
 > gcc-version:
 > Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3/specs
 > Configured with: ../gcc-20030106/configure
 > Thread model: posix
 > gcc version 3.3 20030106 (prerelease)
 >
 > ------ Source code --------------------------------------------------------
 > typedef int __m128 __attribute__ ((__mode__(__V4SF__)));
 >
 > class sse_t {
 >         __m128 d __attribute__((aligned(16)));
 > public:
 >         sse_t();
 >         sse_t operator=(sse_t const &o) { d=o.d; }
 > };
 >
 > class Contour {
 >         sse_t test;
 > public:
 >         Contour();
 > };
 >
 > Contour::Contour()
 > {
 >         sse_t z __attribute__ ((aligned(16)));
 >
 >         test=z;
 > }
 >
 Don't data objects need to be allocated within a method which is called from 
 one which is built with -mpreferred-stack-alignment=4, in order for gcc to 
 apply alignment?  
 
 -- 
 Tim Prince


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-01-13 13:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-13 11:46 target/9290: incorrect alignment when using SSE on ia32 mark
2003-01-13 12:36 Tim Prince
2003-01-13 13:46 m.j.s.vandoesburg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).