Bug 58006 - [4.8/4.9 Regression] ICE compiling VegaStrike with -ffast-math -ftree-parallelize-loops=2
Summary: [4.8/4.9 Regression] ICE compiling VegaStrike with -ffast-math -ftree-paralle...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.8.1
: P3 normal
Target Milestone: 4.8.2
Assignee: Jakub Jelinek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-27 20:51 UTC by ermo.gcc.gnu.org
Modified: 2013-08-18 18:43 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-07-27 00:00:00


Attachments
preprocessed source (265.71 KB, application/gzip)
2013-07-27 20:57 UTC, ermo.gcc.gnu.org
Details
gcc49-pr58006.patch (880 bytes, patch)
2013-08-16 15:30 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description ermo.gcc.gnu.org 2013-07-27 20:51:35 UTC
When trying to compile rev. 13636 of VegaStrike (using the CMake build method) with gcc (GCC) 4.8.1 20130603 (Red Hat 4.8.1-1), g++ ICEs on the following compilation target on both a C2D E7500 and an AMD Athlon II 240e running fedora19 x86_64:

[ermo@sheila build]$ make
/usr/bin/cmake -H/home/ermo/VegaStrike/trunk/vegastrike -B/home/ermo/VegaStrike/trunk/vegastrike/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/ermo/VegaStrike/trunk/vegastrike/build/CMakeFiles /home/ermo/VegaStrike/trunk/vegastrike/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/home/ermo/VegaStrike/trunk/vegastrike/build'
make -f CMakeFiles/OPcollide.dir/build.make CMakeFiles/OPcollide.dir/depend
make[2]: Entering directory `/home/ermo/VegaStrike/trunk/vegastrike/build'
cd /home/ermo/VegaStrike/trunk/vegastrike/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/ermo/VegaStrike/trunk/vegastrike /home/ermo/VegaStrike/trunk/vegastrike /home/ermo/VegaStrike/trunk/vegastrike/build /home/ermo/VegaStrike/trunk/vegastrike/build /home/ermo/VegaStrike/trunk/vegastrike/build/CMakeFiles/OPcollide.dir/DependInfo.cmake --color=
make[2]: Leaving directory `/home/ermo/VegaStrike/trunk/vegastrike/build'
make -f CMakeFiles/OPcollide.dir/build.make CMakeFiles/OPcollide.dir/build
make[2]: Entering directory `/home/ermo/VegaStrike/trunk/vegastrike/build'
make[2]: Nothing to be done for `CMakeFiles/OPcollide.dir/build'.
make[2]: Leaving directory `/home/ermo/VegaStrike/trunk/vegastrike/build'
/usr/bin/cmake -E cmake_progress_report /home/ermo/VegaStrike/trunk/vegastrike/build/CMakeFiles  1 2 3 4 5 6 7 8
[  8%] Built target OPcollide
make -f CMakeFiles/engine_com.dir/build.make CMakeFiles/engine_com.dir/depend
make[2]: Entering directory `/home/ermo/VegaStrike/trunk/vegastrike/build'
cd /home/ermo/VegaStrike/trunk/vegastrike/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/ermo/VegaStrike/trunk/vegastrike /home/ermo/VegaStrike/trunk/vegastrike /home/ermo/VegaStrike/trunk/vegastrike/build /home/ermo/VegaStrike/trunk/vegastrike/build /home/ermo/VegaStrike/trunk/vegastrike/build/CMakeFiles/engine_com.dir/DependInfo.cmake --color=
make[2]: Leaving directory `/home/ermo/VegaStrike/trunk/vegastrike/build'
make -f CMakeFiles/engine_com.dir/build.make CMakeFiles/engine_com.dir/build
make[2]: Entering directory `/home/ermo/VegaStrike/trunk/vegastrike/build'
/usr/bin/cmake -E cmake_progress_report /home/ermo/VegaStrike/trunk/vegastrike/build/CMakeFiles 
[  8%] Building CXX object CMakeFiles/engine_com.dir/src/gfx/cockpit_generic.cpp.o
/usr/bin/c++    -O2  -mtune=native -march=native -mfpmath=sse -msse3 -mmmx -ftree-vectorize -ffast-math -fassociative-math -funsafe-math-optimizations -funroll-loops  -ftree-parallelize-loops=2  -DNV_CUBE_MAP -DBOOST_PYTHON_NO_PY_SIGNATURES -include config.h -pipe -Wall -fvisibility=hidden -I/home/ermo/VegaStrike/trunk/vegastrike/src -I/home/ermo/VegaStrike/trunk/vegastrike/src/cmd -I/home/ermo/VegaStrike/trunk/vegastrike/build -I/usr/include/python2.7 -I/home/ermo/VegaStrike/trunk/vegastrike/boost/1_53 -I/usr/include/AL -I/usr/include/SDL -I/usr/include/vorbis -I/usr/include/ogg    -o CMakeFiles/engine_com.dir/src/gfx/cockpit_generic.cpp.o -c /home/ermo/VegaStrike/trunk/vegastrike/src/gfx/cockpit_generic.cpp
/home/ermo/VegaStrike/trunk/vegastrike/src/gfx/cockpit_generic.cpp: In member function ‘bool Cockpit::Update()’:
/home/ermo/VegaStrike/trunk/vegastrike/src/gfx/cockpit_generic.cpp:494:6: internal compiler error: Segmentation fault
 bool Cockpit::Update()
      ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugzilla.redhat.com/bugzilla> for instructions.
Preprocessed source stored into /tmp/ccnOEb2C.out file, please attach this to your bugreport.
make[2]: *** [CMakeFiles/engine_com.dir/src/gfx/cockpit_generic.cpp.o] Error 1
make[2]: Leaving directory `/home/ermo/VegaStrike/trunk/vegastrike/build'
make[1]: *** [CMakeFiles/engine_com.dir/all] Error 2
make[1]: Leaving directory `/home/ermo/VegaStrike/trunk/vegastrike/build'
make: *** [all] Error 2
[ermo@sheila build]$ 

It turns out that the minimal repro case is adding just -mtune=native -march=native -ffast-math -ftree-parallelize-loops=2 to that particular compilation target.

Note that on fedora18, which uses gcc-4.7.2, the exact same configuration does not result in an ICE.

Vega Strike build instructions can be found here:

http://wiki.vega-strike.org/HowTo:Compile_from_SVN_on_Linux

I used the following ccmake configuration (only differences to default listed):

CPUINTEL_native                  ON
CPU_SMP                          2
DISABLE_FFMPEG                   ON
CMAKE_VERBOSE_MAKEFILE           ON (only listed in the advanced config options)


P.S. I am aware that there might be some redundancy in the build configuration CFLAGS.
Comment 1 Paolo Carlini 2013-07-27 20:57:30 UTC
Per the bug reporting instructions, please attach a preprocessed reproducer. If at all possible, please do your best to reduce it to a manageable size: http://gcc.gnu.org/wiki/A_guide_to_testcase_reduction
Comment 2 ermo.gcc.gnu.org 2013-07-27 20:57:38 UTC
Created attachment 30564 [details]
preprocessed source
Comment 3 ermo.gcc.gnu.org 2013-07-27 21:06:35 UTC
@Paolo:

*sigh* -- I suspected that it wasn't ever going to be as simple as describing what I did to trigger the ICE.  Sorry for polluting bugzilla with an incomplete bug-report.

I'll see what I can do about educating myself on the ways of proper gcc bug-reporting -- you never know if it might come in handy one day. =)
Comment 4 Marc Glisse 2013-07-27 21:23:57 UTC
Confirmed with just -Ofast -ftree-parallelize-loops=2.

#0  __strlen_sse2_pminub () at ../sysdeps/x86_64/multiarch/strlen-sse2-pminub.S:38
#1  0x0000000000cf064b in get_identifier (text=0x0) at /data/repos/gcc/trunk/gcc/stringpool.c:111
#2  0x0000000000d96f46 in make_temp_ssa_name (type=0x7ffff5fb12a0, stmt=0x0, name=0x0)
    at /data/repos/gcc/trunk/gcc/tree-flow-inline.h:1222
#3  0x0000000000d97ee1 in take_address_of (obj=0x7ffff1449f50, type=0x7ffff5fb12a0, entry=0x7ffff0ddad58, decl_address=..., 
    gsi=0x7fffffffd4b0) at /data/repos/gcc/trunk/gcc/tree-parloops.c:499
#4  0x0000000000d9841e in eliminate_local_variables_1 (tp=0x7ffff1840450, walk_subtrees=0x7fffffffd2b8, data=0x7fffffffd3e0)
    at /data/repos/gcc/trunk/gcc/tree-parloops.c:613
#5  0x0000000000f6f75e in walk_tree_1 (tp=0x7ffff1840450, func=0xd982f3 <eliminate_local_variables_1(tree*, int*, void*)>, 
    data=0x7fffffffd3e0, pset=0x0, lh=0x0) at /data/repos/gcc/trunk/gcc/tree.c:10916
#6  0x0000000000a9b35d in walk_gimple_op (stmt=0x7ffff1840410, callback_op=0xd982f3 <eliminate_local_variables_1(tree*, int*, void*)>, 
    wi=0x7fffffffd3e0) at /data/repos/gcc/trunk/gcc/gimple.c:1428
#7  0x0000000000d98727 in eliminate_local_variables_stmt (entry=0x7ffff0ddad58, gsi=0x7fffffffd4b0, decl_address=...)
    at /data/repos/gcc/trunk/gcc/tree-parloops.c:700
#8  0x0000000000d98881 in eliminate_local_variables (entry=0x7ffff0ddad58, exit=0x7ffff1b40a80)
    at /data/repos/gcc/trunk/gcc/tree-parloops.c:743
#9  0x0000000000d9c358 in gen_parallel_loop (loop=0x7ffff0d4bea0, reduction_list=..., n_threads=2, niter=0x7fffffffd5f0)
    at /data/repos/gcc/trunk/gcc/tree-parloops.c:1864
#10 0x0000000000d9d393 in parallelize_loops () at /data/repos/gcc/trunk/gcc/tree-parloops.c:2218
Comment 5 Marc Glisse 2013-07-28 11:45:12 UTC
extern "C" float sqrtf (float);
extern int a;
extern int b;
struct Vector {
  float i;
  float j;
  float Magnitude() const {
    return sqrtf( i*i+j*j );
  }
};
void f(){
  int i   = a;
  int end = b;
  for (; i != end; ++i) {
    float tmag = Vector().Magnitude();
  }
}
Comment 6 Paolo Carlini 2013-07-28 17:10:16 UTC
Thanks Marc.
Comment 7 vincent.legoll 2013-08-12 09:23:16 UTC
Hello, I got the same under Debian Jessie

$ gcc-4.8 -v
Using built-in specs.
COLLECT_GCC=gcc-4.8
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.8.1-2' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --with-arch-32=i586 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.1 (Debian 4.8.1-2)
Comment 8 Jakub Jelinek 2013-08-16 15:30:42 UTC
Created attachment 30666 [details]
gcc49-pr58006.patch

Untested fix.
Comment 9 Jakub Jelinek 2013-08-18 18:43:18 UTC
Author: jakub
Date: Sun Aug 18 15:23:24 2013
New Revision: 201827

URL: http://gcc.gnu.org/viewcvs?rev=201827&root=gcc&view=rev
Log:
	PR tree-optimization/58006
	* tree-parloops.c (take_address_of): Don't ICE if get_name
	returns NULL.
	(eliminate_local_variables_stmt): Remove clobber stmts.

	* g++.dg/opt/pr58006.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/opt/pr58006.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-parloops.c

Author: jakub
Date: Sun Aug 18 15:24:12 2013
New Revision: 201828

URL: http://gcc.gnu.org/viewcvs?rev=201828&root=gcc&view=rev
Log:
	PR tree-optimization/58006
	* tree-parloops.c (take_address_of): Don't ICE if get_name
	returns NULL.
	(eliminate_local_variables_stmt): Remove clobber stmts.

	* g++.dg/opt/pr58006.C: New test.

Added:
    branches/gcc-4_8-branch/gcc/testsuite/g++.dg/opt/pr58006.C
Modified:
    branches/gcc-4_8-branch/gcc/ChangeLog
    branches/gcc-4_8-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_8-branch/gcc/tree-parloops.c