Bug 36837 - x86_64 linux-gnu gcc miscompiles spu-elf gcc (4.4)
Summary: x86_64 linux-gnu gcc miscompiles spu-elf gcc (4.4)
Status: RESOLVED WONTFIX
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.3.1
: P3 normal
Target Milestone: 10.0
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
: 39887 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-07-15 13:52 UTC by gcc_bz
Modified: 2021-05-31 01:04 UTC (History)
1 user (show)

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


Attachments
Preprocessed source (533 bytes, text/plain)
2008-07-15 15:49 UTC, gcc_bz
Details

Note You need to log in before you can comment on or make changes to this bug.
Description gcc_bz 2008-07-15 13:52:01 UTC
For the following fragment :

#include <spu_intrinsics.h>
vector unsigned int f() {
        return spu_splats( (unsigned int)7 );
}


Compiling with spu-elf-gcc is fine.  Compiling with spu-elf-g++ generates an error:

$ usr/bin/spu-elf-g++ -c splat.cpp
splat.cpp: In function 'unsigned int __vector__ f()':
splat.cpp:3: note: use -flax-vector-conversions to permit conversions between vectors with differing element types or numbers of subparts
splat.cpp:3: error: cannot convert 'unsigned char __vector__' to 'unsigned int __vector__' in return


Replacing spu_splats with __builtin_spu_splats_4 allows the fragment to be compiled correctly.



Observed with r137813.  

Compiles as expected in :
gcc version 4.4.0 20080404 (experimental)
gcc version 4.3.0 20071012 (experimental)
gcc version 4.1.1 (IBM SDK 3.0 release)
Comment 1 Andrew Pinski 2008-07-15 13:55:21 UTC
Works for me with:
GNU C++ (GCC) version 4.4.0 20080711 (experimental) [trunk revision 137727] (spu-elf)

So this has to be a very recent regression.
Comment 2 gcc_bz 2008-07-15 14:54:36 UTC
I reverted to r137727 and rebuilt it all and still see the error.

Any obvious mistake in the following?

../gcc/configure --prefix=${HOME}/usr --enable-languages=c,c++ --with-newlib --with-headers --target=spu-elf
make && make install

Other things I should check?
Comment 3 Andrew Pinski 2008-07-15 14:57:13 UTC
These are the options I use:
--target=spu-elf --prefix=${HOME}/gcc-spu --with-mpfr=/usr/local --with-newlib --enable-languages=c,c++,objc --with-headers
Comment 4 Andrew Pinski 2008-07-15 14:58:05 UTC
[apinski@dhcp-10-98-10-216 ~]$ ~/gcc-spu/bin/spu-elf-gcc t.cc -S -v
Using built-in specs.
Target: spu-elf
Configured with: /home/apinski/src/local/gcc/configure --target=spu-elf --prefix=/home/apinski/gcc-spu --with-mpfr=/usr/local --with-newlib --enable-languages=c,c++,objc --with-headers
Thread model: single
gcc version 4.4.0 20080711 (experimental) [trunk revision 137727] (GCC) 
COLLECT_GCC_OPTIONS='-S' '-v'
 /home/apinski/gcc-spu/libexec/gcc/spu-elf/4.4.0/cc1plus -quiet -v t.cc -quiet -dumpbase t.cc -auxbase t -version -o t.s
ignoring nonexistent directory "/home/apinski/gcc-spu/lib/gcc/spu-elf/4.4.0/../../../../spu-elf/sys-include"
#include "..." search starts here:
#include <...> search starts here:
 /home/apinski/gcc-spu/lib/gcc/spu-elf/4.4.0/../../../../spu-elf/include/c++/4.4.0
 /home/apinski/gcc-spu/lib/gcc/spu-elf/4.4.0/../../../../spu-elf/include/c++/4.4.0/spu-elf
 /home/apinski/gcc-spu/lib/gcc/spu-elf/4.4.0/../../../../spu-elf/include/c++/4.4.0/backward
 /home/apinski/gcc-spu/lib/gcc/spu-elf/4.4.0/include
 /home/apinski/gcc-spu/lib/gcc/spu-elf/4.4.0/include-fixed
 /home/apinski/gcc-spu/lib/gcc/spu-elf/4.4.0/../../../../spu-elf/include
End of search list.
GNU C++ (GCC) version 4.4.0 20080711 (experimental) [trunk revision 137727] (spu-elf)
        compiled by GNU C version 4.1.0 20060304 (Red Hat 4.1.0-3), GMP version 4.2.1, MPFR version 2.2.1.
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: 6f14eb7742734115a119ca07da3cf037
COMPILER_PATH=/home/apinski/gcc-spu/libexec/gcc/spu-elf/4.4.0/:/home/apinski/gcc-spu/libexec/gcc/spu-elf/4.4.0/:/home/apinski/gcc-spu/libexec/gcc/spu-elf/:/home/apinski/gcc-spu/lib/gcc/spu-elf/4.4.0/:/home/apinski/gcc-spu/lib/gcc/spu-elf/:/home/apinski/gcc-spu/lib/gcc/spu-elf/4.4.0/../../../../spu-elf/bin/
LIBRARY_PATH=/home/apinski/gcc-spu/lib/gcc/spu-elf/4.4.0/:/home/apinski/gcc-spu/lib/gcc/spu-elf/4.4.0/../../../../spu-elf/lib/
COLLECT_GCC_OPTIONS='-S' '-v'
Comment 5 gcc_bz 2008-07-15 15:49:59 UTC
Created attachment 15912 [details]
Preprocessed source

$ usr/bin/spu-elf-g++ splat.cpp -v
Using built-in specs.
Target: spu-elf
Configured with: ../gcc/configure --prefix=/home/jonathan/usr --enable-languages=c,c++ --with-newlib --with-headers --target=spu-elf
Thread model: single
gcc version 4.4.0 20080711 (experimental) (GCC)
COLLECT_GCC_OPTIONS='-v'
 /home/jonathan/usr/libexec/gcc/spu-elf/4.4.0/cc1plus -quiet -v splat.cpp -quiet -dumpbase splat.cpp -auxbase splat -version -o /tmp/ccxYOpg1.s
ignoring nonexistent directory "/home/jonathan/usr/lib/gcc/spu-elf/4.4.0/../../../../spu-elf/sys-include"
#include "..." search starts here:
#include <...> search starts here:
 /home/jonathan/usr/lib/gcc/spu-elf/4.4.0/../../../../spu-elf/include/c++/4.4.0
 /home/jonathan/usr/lib/gcc/spu-elf/4.4.0/../../../../spu-elf/include/c++/4.4.0/spu-elf
 /home/jonathan/usr/lib/gcc/spu-elf/4.4.0/../../../../spu-elf/include/c++/4.4.0/backward
 /home/jonathan/usr/lib/gcc/spu-elf/4.4.0/include
 /home/jonathan/usr/lib/gcc/spu-elf/4.4.0/include-fixed
 /home/jonathan/usr/lib/gcc/spu-elf/4.4.0/../../../../spu-elf/include
End of search list.
GNU C++ (GCC) version 4.4.0 20080711 (experimental) (spu-elf)
        compiled by GNU C version 4.3.1, GMP version 4.2.2, MPFR version 2.3.1.
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: 0796f6f7f5d948d81ac2e84f3843bd7d
splat.cpp: In function 'unsigned int __vector__ f()':
splat.cpp:3: note: use -flax-vector-conversions to permit conversions between vectors with differing element types or numbers of subparts
splat.cpp:3: error: cannot convert 'unsigned char __vector__' to 'unsigned int __vector__' in return
Comment 6 Andrew Pinski 2008-07-15 15:54:10 UTC
Maybe 4.3.1 is miscompiling GCC 4.4.0 here.
Comment 7 gcc_bz 2008-07-15 15:56:32 UTC
I tried a build using 4.2.4 - same problem.
Comment 8 gcc_bz 2008-07-16 03:48:38 UTC
Tried again building with 4.2.4 (and this time with no ccache :\)  Code compiles as expected.  It appears that the 4.3.1 that I have has problems.

Trying again with fsf gcc-4.3.1.

Comment 9 gcc_bz 2008-07-16 04:54:12 UTC
../gcc-4.3.1/configure --prefix=${HOME}/gcc-native/ --enable-languages=c
make && make install

CC=~/gcc-native/bin/gcc ../gcc/configure --prefix=${HOME}/gcc-spu --enable-languages=c,c++ --with-newlib --with-headers --target=spu-elf
make -j4 CC=~/gcc-native/bin/gcc && make CC=~/gcc-native/bin/gcc install




$ gcc-spu/bin/spu-elf-g++ splat.cpp -c -v
Using built-in specs.
Target: spu-elf
Configured with: ../gcc/configure --prefix=/home/jonathan/gcc-spu --enable-languages=c,c++ --with-newlib --with-headers --target=spu-elf
Thread model: single
gcc version 4.4.0 20080716 (experimental) (GCC)
COLLECT_GCC_OPTIONS='-c' '-v'
 /home/jonathan/gcc-spu/libexec/gcc/spu-elf/4.4.0/cc1plus -quiet -v splat.cpp -quiet -dumpbase splat.cpp -auxbase splat -version -o /tmp/ccTwlij4.s
ignoring nonexistent directory "/home/jonathan/gcc-spu/lib/gcc/spu-elf/4.4.0/../../../../spu-elf/sys-include"
#include "..." search starts here:
#include <...> search starts here:
 /home/jonathan/gcc-spu/lib/gcc/spu-elf/4.4.0/../../../../spu-elf/include/c++/4.4.0
 /home/jonathan/gcc-spu/lib/gcc/spu-elf/4.4.0/../../../../spu-elf/include/c++/4.4.0/spu-elf
 /home/jonathan/gcc-spu/lib/gcc/spu-elf/4.4.0/../../../../spu-elf/include/c++/4.4.0/backward
 /home/jonathan/gcc-spu/lib/gcc/spu-elf/4.4.0/include
 /home/jonathan/gcc-spu/lib/gcc/spu-elf/4.4.0/include-fixed
 /home/jonathan/gcc-spu/lib/gcc/spu-elf/4.4.0/../../../../spu-elf/include
End of search list.
GNU C++ (GCC) version 4.4.0 20080716 (experimental) (spu-elf)
        compiled by GNU C version 4.3.1, GMP version 4.2.2, MPFR version 2.3.1.
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: b3d5544b58f1447fbeb69330a4fd2dff
splat.cpp: In function 'unsigned int __vector__ f()':
splat.cpp:3: note: use -flax-vector-conversions to permit conversions between vectors with differing element types or numbers of subparts
splat.cpp:3: error: cannot convert 'unsigned char __vector__' to 'unsigned int __vector__' in return
Comment 10 gcc_bz 2008-07-16 04:55:03 UTC
In other words, gcc-4.3.1 creates a wrong-functioning spu-elf-g++
Comment 11 gcc_bz 2009-04-25 13:31:33 UTC
*** Bug 39887 has been marked as a duplicate of this bug. ***
Comment 12 Andrew Pinski 2021-05-31 01:04:33 UTC
spu as a target has been removed since GCC 10.