This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[c-wrongcode-severe] mmx asm inline & const arrays
- To: gcc-bugs at gcc dot gnu dot org
- Subject: [c-wrongcode-severe] mmx asm inline & const arrays
- From: pl <p_l at tfz dot net>
- Date: Tue, 24 Jul 2001 22:16:54 +0200
Hi,
gcc-3.0/3.0.1-pre does not produce the code expected at optimization
level -Ox (x>=1) for main/libavcodec/i386/mpegvideo.c with MMX enabled
in mplayer (preprocessed file attached).
The problem comes from the use of the const attribute for the two data
arrays (mm_wabs[], mm_wone[]).
As far as I can tell, expected code (first part of inline asm)n
dct_unquantize() is:
[...]
movd %edi, %mm6
punpckldq %mm6, %mm6
movq mm_wabs, %mm4 *
movq %mm6, %mm7
movq mm_wone, %mm5 *
packssdw %mm6, %mm7
pxor %mm6, %mm6
[...]
(this code is found in -O0 or with gcc 2.95.x)
which effectively corresponds to what is expected load register %mm?
with the 8 bytes of mm_w???[].
gcc-3.0.x at -O4 generate the following "evil" code:
[...]
.LC113:
.value 1
.align 2
.LC114:
.value 65535
.text
.align 16
[...]
movd %edi, %mm6
punpckldq %mm6, %mm6
movq .LC114, %mm4 *
movq %mm6, %mm7
movq .LC113, %mm5 *
packssdw %mm6, %mm7
pxor %mm6, %mm6
[...]
And there it does not load what it should since 8 bytes are loaded in
the MMX register but only 2 are correctly initialized.
Best regards.
GCC version
-----------
Reading specs from /usr/lib/gcc-lib/i386-linux/3.0.1/specs
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
Thread model: posix
gcc version 3.0.1 20010721 (Debian prerelease)
Command line
------------
gcc-3.0 -O4 -march=i686 -mcpu=i686 -pipe -ffast-math -fomit-frame-pointer -Wall -c -o mpegvideo.o mpegvideo.c
mpegvideo.c: In function `MPV_common_init':
mpegvideo.c:136: warning: implicit declaration of function `memset'
rm -f libavcodec.a
ar rcs libavcodec.a common.o utils.o mpegvideo.o h263.o jrevdct.o jfdctfst.o mpegaudio.o ac3enc.o mjpegenc.o resample.o dsputil.o motion_est.o imgconvert.o imgresample.o msmpeg4.o mpeg12.o h263dec.o mpegaudiodec.o i386/fdctdata.o i386/fdct_mmx.o i386/sad_mmx.o
mpegvideo.i.gz