Bug 14110 - altivec code misoptimized with any -O
Summary: altivec code misoptimized with any -O
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 3.3.2
: P2 normal
Target Milestone: 3.4.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-02-11 14:13 UTC by lu_zero
Modified: 2005-07-23 22:49 UTC (History)
3 users (show)

See Also:
Host: powerpc-unknown-linux-gnu
Target: powerpc-unknown-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Preprocessed source (36.65 KB, application/x-tar)
2004-02-11 14:25 UTC, lu_zero
Details
source (2.28 KB, text/plain)
2004-02-11 17:15 UTC, lu_zero
Details
Preprocessed source (42.54 KB, application/x-bzip2)
2004-03-15 12:14 UTC, Jonathan Gray
Details

Note You need to log in before you can comment on or make changes to this bug.
Description lu_zero 2004-02-11 14:13:21 UTC
that problem happens while building libavicodec's idct_altivec.c.
I restricted the issue inq the idct_add_altivec() function.

the code is usually built with 
"-O4 -mcpu=7450 -mtune=7450 -maltivec -mabi=altivec -pipe -ffast-math
-fomit-frame-pointer" and with gcc-3.2.3 produces correct code.

if I change it removing -O4 and not putting any other -O (tested -O2 and -O1)
the result is a fully working code.
Comment 1 lu_zero 2004-02-11 14:25:58 UTC
Created attachment 5724 [details]
Preprocessed source
Comment 2 Andrew Pinski 2004-02-11 16:46:28 UTC
Can you provide the non-preprocessed source as looking to the preprocessed source for altivec is a 
pain?
Comment 3 lu_zero 2004-02-11 17:15:30 UTC
Created attachment 5725 [details]
source
Comment 4 Jonathan Gray 2004-03-15 12:10:30 UTC
I have something similiar when attempting to build mpegvideo_altivec.c from ffmpeg. 

The following command always gives an ICE:
gcc -Wall  -maltivec -mabi=altivec -g -O3 -DHAVE_AV_CONFIG_H -I..
-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE -c -o
ppc/mpegvideo_altivec.o ppc/mpegvideo_altivec.c

Only when dropping -O entirely does it compile.

Output when adding -v and -save-tempts is as follows:

Reading specs from /usr/lib/gcc-lib/powerpc-linux/3.3.3/specs
Configured with: ../src/configure -v
--enable-languages=c,c++,java,f77,pascal,objc,ada --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --with-system-zlib
--enable-nls --without-included-gettext --enable-__cxa_atexit
--enable-clocale=gnu --enable-java-gc=boehm --enable-java-awt=xlib
--enable-objc-gc --disable-multilib powerpc-linux
Thread model: posix
gcc version 3.3.3 (Debian 20040306)
 /usr/lib/gcc-lib/powerpc-linux/3.3.3/cc1 -E -quiet -v -I.. -D__GNUC__=3
-D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=3 -D__unix__ -D__gnu_linux__
-D__linux__ -Dunix -D__unix -Dlinux -D__linux -Asystem=unix -Asystem=posix
-DHAVE_AV_CONFIG_H -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE
ppc/mpegvideo_altivec.c -maltivec -mabi=altivec -Wall -O3 mpegvideo_altivec.i
ignoring nonexistent directory "/usr/powerpc-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 ..
 /usr/local/include
 /usr/lib/gcc-lib/powerpc-linux/3.3.3/include
 /usr/include
End of search list.
 /usr/lib/gcc-lib/powerpc-linux/3.3.3/cc1 -fpreprocessed mpegvideo_altivec.i
-quiet -dumpbase mpegvideo_altivec.c -maltivec -mabi=altivec -auxbase-strip
ppc/mpegvideo_altivec.o -g -O3 -Wall -version -o mpegvideo_altivec.s
GNU C version 3.3.3 (Debian 20040306) (powerpc-linux)
        compiled by GNU C version 3.3.3 (Debian 20040306).
GGC heuristics: --param ggc-min-expand=72 --param ggc-min-heapsize=80312
ppc/mpegvideo_altivec.c: In function `dct_quantize_altivec':
ppc/mpegvideo_altivec.c:516: internal compiler error: in
add_location_or_const_value_attribute, at dwarf2out.c:9496
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
Comment 5 Jonathan Gray 2004-03-15 12:14:10 UTC
Created attachment 5919 [details]
Preprocessed source
Comment 6 Andrew Pinski 2004-03-15 14:19:31 UTC
Jonathan Gray,
Your bug is that 3.3.3 did not have a patch to fix that ICE, it has been fixed already in 3.3.4.
Comment 7 Giovanni Bajo 2004-10-11 10:45:41 UTC
Lu Zero, I'm revisiting this bug report. The testcase you provided cannot be 
executed to check for the miscompilation, which makes it very difficult for us 
to check for the problem.

Would you please provide a testcase with a main() invoking idc_add_altivec() 
with some valid parameters, and aborting if the result is incorrect (assuming 
it does not crash right way because of the miscompilation)?

Thanks
Comment 8 lu_zero 2004-10-11 17:16:01 UTC
Fixed at least on gcc-3.4.x and in the hammer branch.
gcc-3.3.4 should have other problems (I didn't check yet)

the best way to check about the problem works is just use mplayer or ffplay...
Comment 9 Andrew Pinski 2004-10-11 17:20:56 UTC
Fixed so closing.