Submitter-Id:   net
Originator:     Pierre Lombard
Synopsis:       wrongcode when optimizing mmx asm inline
Severity:       serious
Priority:       medium
Confidential:   no
Category:       optimization
Class:          wrong-code
Release:        3.0.3 (Debian testing/unstable)
Environment:
System: Linux s41 2.4.17 #2 SMP Sat Dec 29 12:34:41 CET 2001 i686 unknown
Architecture: i686

        <machine, os, target, libraries (multiple lines)>
host: i386-pc-linux-gnu
build: i386-pc-linux-gnu
target: i386-pc-linux-gnu
configured with: ../src/configure -v 
--enable-languages=c,c++,java,f77,proto,objc --prefix=/usr 
--infodir=/share/info --mandir=/share/man --enable-shared --with-gnu-as 
--with-gnu-ld --with-system-zlib --enable-long-long --enable-nls 
--without-included-gettext --disable-checking --enable-threads=posix 
--enable-java-gc=boehm --with-cpp-install-dir=bin --enable-objc-gc i386-linux

Description:

I had already filed a bug report in July 2001 but there was neither follow-up
nor reply.  It's archived here:
  http://gcc.gnu.org/ml/gcc-bugs/2001-07/msg00910.html.

        With -O0 (correct code - ok with -O1 too):
...
        .section        .rodata
        .align 8
        .type   mm_wabs,@object
        .size   mm_wabs,8
mm_wabs:
        .value  65535
        .value  65535
        .value  65535
        .value  65535
        .align 8
        .type   mm_wone,@object
        .size   mm_wone,8
mm_wone:
        .value  1
        .value  1
        .value  1
        .value  1
        .text
        .align 4
        .type   dct_unquantize,@function
...
#APP
        movd    20(%ebp), %mm6
        punpckldq %mm6, %mm6
        movq    mm_wabs, %mm4                   //XXX
        movq    %mm6, %mm7
        movq    mm_wone, %mm5                   //XXX
        packssdw %mm6, %mm7
        pxor    %mm6, %mm6

        .p2align 2
#NO_APP
...


        With -O2 (and above => the same problem appears):

.Lfe6:
        .size   draw_edges,.Lfe6-draw_edges
        .section        .rodata
        .align 8
        .type   mm_wabs,@object
        .size   mm_wabs,8
mm_wabs:
        .value  65535
        .value  65535
        .value  65535
        .value  65535
        .align 8
        .type   mm_wone,@object
        .size   mm_wone,8
mm_wone:
        .value  1
        .value  1
        .value  1
        .value  1
        .align 2
.LC113:
        .value  1
        .align 2
.LC114:
        .value  65535
        .text
        .align 4
        .type   dct_unquantize,@function
...
#APP
        movd    %edi, %mm6
        punpckldq %mm6, %mm6
        movq    .LC114, %mm4                    // XXX
        movq    %mm6, %mm7
        movq    .LC113, %mm5                    // XXX
        packssdw %mm6, %mm7
        pxor    %mm6, %mm6

#NO_APP
...

I still think mm4 and mm5 are not initialized to the same values -O0 and -O2
with 3.0.3.  Can somebody confirm it's a bug (or explain me why it is not) ?

How-To-Repeat:
Just compile it with: gcc-3.0 -O[02] -S mpegvideo.i

The preprocesses file has already been uploaded:
        http://gcc.gnu.org/ml/gcc-bugs/2001-07/msg00910/mpegvideo.i.gz

Fix:
A workaround is to use a 64bits unsigned long long.
Another one is to compile with -O0.


Reply via email to