Bug 15386 - WMA decoder miscompiled with -O4 -mcpu=k6 - one pop, no sound
Summary: WMA decoder miscompiled with -O4 -mcpu=k6 - one pop, no sound
Status: RESOLVED DUPLICATE of bug 323
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-05-11 20:57 UTC by Diego Biurrun
Modified: 2004-07-19 11:50 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 2.95.3 3.0.4
Known to fail: 3.1 3.1.1 3.2.3 3.3.2 3.4.0
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Diego Biurrun 2004-05-11 20:57:15 UTC
MPlayer triggers another compiler bug...

The WMA (Windows Media audio codec) decoder of FFmpeg/libavcodec
(http://ffmpeg.org) wmadec.c gets miscompiled by gcc versions >=3.1 when
compiled with -mcpu=k6 and/or -O1 or above.  When playing a WMA sample with
MPlayer all you get is pop at the beginning and then no sound.  The problem
disappears with either -mcpu=pentium-mmx or -O0 (changing one parameter is
enough to make the problem go away, either one works).

Here is the complete command line and output when compiling the file:

/var/tmp/gcc-3.5-20040502/bin/gcc -I../libvo/ -I../../libvo -I/usr/X11R6/include
-g -O4 -march=k6 -mcpu=k6 -pipe -ffast-math -fomit-frame-pointer -D_REENTRANT
-I/usr/include/gtk-1.2 -I/usr/include/glib-1.2 -I/usr/lib/glib/include
-DHAVE_AV_CONFIG_H -I.. -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE
-Wall -save-temps -c -o wmadec.o wmadec.c && make && cd .. && make
gcc: warning: -pipe ignored because -save-temps specified
`-mcpu=' is deprecated. Use `-mtune=' or '-march=' instead.

I have tried several gcc versions, 2.95.3 and 3.0.4 are OK, 3.1, 3.1.1, 3.2.3,
3.3.2, 3.4.0 and 3.5.0-20040502 all display the problem.

gcc -v output:
Configured with: ../gcc-3.1/configure --prefix=/var/tmp/gcc-3.1/
Thread model: single
gcc version 3.1

I put the file together with all the headers necessary to compile it, the .o and
.i files and a sample to test the broken sound with MPlayer on my homepage:

http://www.mplayerhq.hu/~diego/gcc/

If you require further info or testing I will be more than happy to provide it.
Comment 1 Andrew Pinski 2004-05-11 22:36:16 UTC
Does adding -fno-strict-aliasing work?
Comment 2 Diego Biurrun 2004-05-11 23:19:00 UTC
No, -fno-strict-aliasing does not help.
Comment 3 Eric Botcazou 2004-05-12 06:05:13 UTC
Which version of binutils do you use?
Comment 4 Diego Biurrun 2004-05-12 08:09:56 UTC
binutils version: 2.14.90.0.7-6

Some more information: My machine is a K6-III 500 running current Debian
unstable with a homebrewed 2.4.25 kernel.
Comment 5 Andrew Pinski 2004-05-12 13:13:34 UTC
Does lowering the optimization to -O2 help? (Note -O4 is the same as -O3).
Comment 6 Diego Biurrun 2004-05-12 13:41:46 UTC
No, -O2 does not help.  As noted above the problem goes away with -O0 (-O1 still
has the bug) or -mcpu=pentium-mmx or both.
Comment 7 Wolfgang Bangerth 2004-05-12 13:49:45 UTC
One of the things that would really help us is if you could split 
up the one file that is miscompiled into a number of files each 
of which has exactly one function, and try to figure out which 
function is miscompiled. One of the reasons why we have trouble 
doing anything with your report except for poking in the dark is 
because it is very hard to figure out what exactly goes wrong in 
applications that we don't know, and we usually need quite some help 
from application developers to figure out where the bug is. So if 
you could try to cut the problem down to one or a few functions, it 
would be a tremendous help. The next step is to determine for which 
arguments this function does the wrong thing, and to put together 
a small testcase where this one function is called with just these 
parameters for which the output is known. 
 
Thanks 
  Wolfgang 
Comment 8 Eric Botcazou 2004-05-15 06:10:02 UTC
We need a preprocessed testcase to start working on it.
Comment 9 Diego Biurrun 2004-07-18 11:07:41 UTC
small remark: Adding -fno-inline to the compilation flags does not help.
Comment 10 Diego Biurrun 2004-07-18 12:08:34 UTC
I managed to split the file in two and isolate the bug to a small part of the
original file that only contains two functions, a large and a small one.

void wma_lsp_to_curve_init(WMADecodeContext *s, int frame_len)
int wma_decode_init(AVCodecContext * avctx)

All relevant files and the output of gcc can be found at

http://www.mplayerhq.hu/~diego/gcc/

I hope this satisfies your requirements, if there is anything else I can do,
please let me know.
Comment 11 Andrew Pinski 2004-07-18 14:25:41 UTC
Does -ffloat-store help at all?
Comment 12 Diego Biurrun 2004-07-19 00:49:50 UTC
-ffloat-store fixes the problem.
Comment 13 Andrew Pinski 2004-07-19 01:19:18 UTC
This is a dup of bug 323, the problem is with excessive precession.

*** This bug has been marked as a duplicate of 323 ***
Comment 14 Diego Biurrun 2004-07-19 11:50:35 UTC
Hmmm, how can a bug that started appearing with 3.1 be duped against a bug open
against 2.95.2 when 2.95.3 has no problems at all?