This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug inline-asm/55864] New: Optimization cause asm code to wrong behaviour


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

             Bug #: 55864
           Summary: Optimization cause asm code to wrong behaviour
    Classification: Unclassified
           Product: gcc
           Version: 4.4.5
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: inline-asm
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: beldmit@nm.ru


The code behaves differently with -O1 and without optimization.

void _xor64_asm(const unsigned char * arg1, const unsigned char * arg2,
unsigned char* out)
{
  __asm__( 
  "movq (%1), %%mm0;"
  "movq (%2), %%mm1;"
  "pxor %%mm0, %%mm1;"
: "=ym"(out)
: "r"(arg1), "r"(arg2)
:  "memory");
__asm__(
  "movl %0, %%ecx;"
  "movq %%mm1, (%%ecx);"
: "=ym"(out)
:
:  "memory"
  );
}

beldmit@manul2$ gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.4.5-8'
--with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.4 --enable-shared --enable-multiarch
--enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.4 --libdir=/usr/lib --enable-nls
--enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc
--enable-targets=all --with-arch-32=i586 --with-tune=generic
--enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu
--target=i486-linux-gnu
Thread model: posix
gcc version 4.4.5 (Debian 4.4.5-8) 

The code is compiled as 
gcc xor.c -o xor -msse2 -O1 -std=c99


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]