public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug inline-asm/19111] New: Alignment ignored if optimizing for size
@ 2004-12-21 16:32 alonsoschaich at gmx dot de
  2004-12-21 16:33 ` [Bug inline-asm/19111] " alonsoschaich at gmx dot de
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: alonsoschaich at gmx dot de @ 2004-12-21 16:32 UTC (permalink / raw)
  To: gcc-bugs

Hello,   
   
Please correct me if this is just invalid code, but it compiles and runs   
perfectly when compiled with -O0, -O1, -O2 or when build with intelC...   
   
I've reduced it to this:   
   
int main()   
 {   
  float __attribute__((aligned(16))) aligned_field[4];   
     
   asm   
    (   
     "leal        %0,   %%edx\n" // load pointer to this->data[0]   
     "movaps (%%edx),  %%xmm0\n" // use aligned instruction   
     :   
     :"m"(aligned_field[0])   
     :"edx","xmm0"   
    );   
       
  return 0;   
 }   
  
GDB tells the application crashes in movaps. If I use movups it works with  
-Os. If I do something __productive__ with the data in the field, the -O3  
binary doesn't crash, but I get false results, while -O2 and less work well. 
 
gcc -v says: 
 
Reading specs from /usr/lib/gcc/i686-pc-linux-gnu/3.4.3/specs 
Configured with: /var/tmp/portage/gcc-3.4.3-r1/work/gcc-3.4.3/configure 
--enable-version-specific-runtime-libs --prefix=/usr 
--bindir=/usr/i686-pc-linux-gnu/gcc-bin/3.4.3 
--includedir=/usr/lib/gcc/i686-pc-linux-gnu/3.4.3/include 
--datadir=/usr/share/gcc-data/i686-pc-linux-gnu/3.4.3 
--mandir=/usr/share/gcc-data/i686-pc-linux-gnu/3.4.3/man 
--infodir=/usr/share/gcc-data/i686-pc-linux-gnu/3.4.3/info 
--with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/3.4.3/include/g++-v3 
--host=i686-pc-linux-gnu --disable-altivec --enable-nls 
--without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu 
--with-system-zlib --disable-checking --disable-werror 
--disable-libunwind-exceptions --enable-shared --enable-threads=posix 
--disable-multilib --enable-java-awt=gtk 
--enable-languages=c,c++,f77,objc,java 
Thread model: posix 
gcc version 3.4.3 20041125 (Gentoo Linux 3.4.3-r1, ssp-3.4.3-0, pie-8.7.7)

-- 
           Summary: Alignment ignored if optimizing for size
           Product: gcc
           Version: 3.4.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: inline-asm
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: alonsoschaich at gmx dot de
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19111


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

* [Bug inline-asm/19111] Alignment ignored if optimizing for size
  2004-12-21 16:32 [Bug inline-asm/19111] New: Alignment ignored if optimizing for size alonsoschaich at gmx dot de
@ 2004-12-21 16:33 ` alonsoschaich at gmx dot de
  2004-12-21 16:34 ` alonsoschaich at gmx dot de
  2004-12-21 17:26 ` rth at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: alonsoschaich at gmx dot de @ 2004-12-21 16:33 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From alonsoschaich at gmx dot de  2004-12-21 16:33 -------
Created an attachment (id=7798)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=7798&action=view)
.ii file


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19111


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

* [Bug inline-asm/19111] Alignment ignored if optimizing for size
  2004-12-21 16:32 [Bug inline-asm/19111] New: Alignment ignored if optimizing for size alonsoschaich at gmx dot de
  2004-12-21 16:33 ` [Bug inline-asm/19111] " alonsoschaich at gmx dot de
@ 2004-12-21 16:34 ` alonsoschaich at gmx dot de
  2004-12-21 17:26 ` rth at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: alonsoschaich at gmx dot de @ 2004-12-21 16:34 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |3.3.4 3.4.3


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19111


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

* [Bug inline-asm/19111] Alignment ignored if optimizing for size
  2004-12-21 16:32 [Bug inline-asm/19111] New: Alignment ignored if optimizing for size alonsoschaich at gmx dot de
  2004-12-21 16:33 ` [Bug inline-asm/19111] " alonsoschaich at gmx dot de
  2004-12-21 16:34 ` alonsoschaich at gmx dot de
@ 2004-12-21 17:26 ` rth at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: rth at gcc dot gnu dot org @ 2004-12-21 17:26 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From rth at gcc dot gnu dot org  2004-12-21 17:25 -------
If movaps crashes in main, it means your libc is broken and isn't aligning
the stack before main.  GCC does add some code to main to realign the end
of the stack, but that doesn't help main itself.  You'd have to move your
code to a new function like so:

    static int __attribute__((noinline)) main1 (int ac, char **av)
    {
      /* whatever */
    }
    int main(int ac, char **av)
    {
      return main1(ac, av);
    }

In either case, gcc has done all it can do.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19111


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

end of thread, other threads:[~2004-12-21 17:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-21 16:32 [Bug inline-asm/19111] New: Alignment ignored if optimizing for size alonsoschaich at gmx dot de
2004-12-21 16:33 ` [Bug inline-asm/19111] " alonsoschaich at gmx dot de
2004-12-21 16:34 ` alonsoschaich at gmx dot de
2004-12-21 17:26 ` rth at gcc dot gnu dot org

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).