The compiler crashes with the given code. Multiple (in fact probably all) versions are affected. Tested versions are 4.7, 4.8, 4.9, 5.1, 5.3 and 6.0 (4.6 and earlier don't accept -mavx2). Exact versions and abort messages are given below. Thanks! The code: ////////////////////////////////////////////////////////// #include <immintrin.h> struct SIMD { __m256d data; SIMD() {}; SIMD (double val) { } SIMD(__m256d _data) { data = _data; } SIMD operator* (SIMD a) { return a; } }; struct Foo { SIMD val; SIMD dval[2]; __attribute__((__always_inline__)) SIMD & Value() throw() { return val; } __attribute__((__always_inline__)) Foo operator* ( const Foo & y) throw() { Foo res; SIMD hx; SIMD hy; res.Value() = hx*hy; res.dval[0] = hx*hy; return res; } }; template<typename Tx> __attribute__((__always_inline__)) void inlineFunc(Tx hx[]) { Tx x = hx[0], y = hx[1]; Tx lam[1] = (x*y); } void FooBarFunc () { Foo adp[2]; inlineFunc (adp); } ////////////////////////////////////////////////////////// Abort messages: ================================================================= g++-4.7 -v Using built-in specs. COLLECT_GCC=g++-4.7 COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.7.3-12ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-gnu-unique-object --disable-libmudflap --enable-plugin --with-system-zlib --enable-objc-gc --with-cloog --enable-cloog-backend=ppl --disable-cloog-version-check --disable-ppl-version-check --enable-multiarch --disable-werror --with-arch-32=i686 --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.7.3 (Ubuntu/Linaro 4.7.3-12ubuntu1) g++-4.7 -mavx2 -O2 -c simd.cpp simd.cpp:27:41: warning: always_inline function might not be inlinable [-Wattributes] simd.cpp: In function ‘void inlineFunc(Tx*) [with Tx = Foo]’: simd.cpp:35:1: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <file:///usr/share/doc/gcc-4.7/README.Bugs> for instructions. Preprocessed source stored into /tmp/cc7UN6UV.out file, please attach this to your bugreport. ERROR: Cannot create report: [Errno 17] File exists: '/var/crash/_usr_lib_gcc_x86_64-linux-gnu_4.7_cc1plus.1028.crash' ================================================================= g++-4.8 -v Using built-in specs. COLLECT_GCC=g++-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='Ubuntu 4.8.2-19ubuntu1' --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 --disable-libmudflap --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 --disable-werror --with-arch-32=i686 --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.2 (Ubuntu 4.8.2-19ubuntu1) g++-4.8 -mavx2 -O2 -c simd.cpp simd.cpp:27:41: warning: always_inline function might not be inlinable [-Wattributes] __attribute__((__always_inline__)) void inlineFunc(Tx hx[]) { ^ simd.cpp: In function ‘void FooBarFunc()’: simd.cpp:34:19: internal compiler error: in make_ssa_name_fn, at tree-ssanames.c:120 inlineFunc (adp); ^ Please submit a full bug report, with preprocessed source if appropriate. See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions. Preprocessed source stored into /tmp/cc4OHJf8.out file, please attach this to your bugreport. ERROR: Cannot create report: [Errno 17] File exists: '/var/crash/_usr_lib_gcc_x86_64-linux-gnu_4.8_cc1plus.1028.crash' ================================================================= g++-4.9 -v Using built-in specs. COLLECT_GCC=g++-4.9 COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.9/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.9.1-3ubuntu2~14.04.1' --with-bugurl=file:///usr/share/doc/gcc-4.9/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.9 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.9 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-vtable-verify --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.9-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.9-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --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.9.1 (Ubuntu 4.9.1-3ubuntu2~14.04.1) g++-4.9 -mavx2 -O2 -c simd.cpp simd.cpp:27:41: warning: always_inline function might not be inlinable [-Wattributes] __attribute__((__always_inline__)) void inlineFunc(Tx hx[]) { ^ simd.cpp: In function ‘void FooBarFunc()’: simd.cpp:34:19: internal compiler error: in make_ssa_name_fn, at tree-ssanames.c:136 inlineFunc (adp); ^ Please submit a full bug report, with preprocessed source if appropriate. See <file:///usr/share/doc/gcc-4.9/README.Bugs> for instructions. Preprocessed source stored into /tmp/ccZAXDyC.out file, please attach this to your bugreport. ================================================================= g++-5 -v Using built-in specs. COLLECT_GCC=/usr/bin/g++-5 COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.1.0-0ubuntu11~14.04.1' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=c++98 --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --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-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --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 5.1.0 (Ubuntu 5.1.0-0ubuntu11~14.04.1) g++-5 -mavx2 -O2 -c simd.cpp simd.cpp:27:41: warning: always_inline function might not be inlinable [-Wattributes] __attribute__((__always_inline__)) void inlineFunc(Tx hx[]) { ^ simd.cpp: In function ‘void FooBarFunc()’: simd.cpp:34:19: internal compiler error: in make_ssa_name_fn, at tree-ssanames.c:150 inlineFunc (adp); ^ 0xc25cab make_ssa_name_fn(function*, tree_node*, gimple_statement_base*) ../../src/gcc/tree-ssanames.c:147 0xb05fa7 make_ssa_name ../../src/gcc/tree-ssanames.h:107 0xb05fa7 remap_ssa_name ../../src/gcc/tree-inline.c:280 0xb080af remap_gimple_op_r ../../src/gcc/tree-inline.c:901 0xc965a4 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, default_hashset_traits>*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, default_hashset_traits>*)) ../../src/gcc/tree.c:11093 0x9020b4 walk_gimple_op(gimple_statement_base*, tree_node* (*)(tree_node**, int*, void*), walk_stmt_info*) ../../src/gcc/gimple-walk.c:282 0xb06fbc remap_gimple_stmt ../../src/gcc/tree-inline.c:1729 0xb08e30 copy_bb ../../src/gcc/tree-inline.c:1788 0xb08e30 copy_cfg_body ../../src/gcc/tree-inline.c:2745 0xb08e30 copy_body ../../src/gcc/tree-inline.c:2984 0xb0ba06 expand_call_inline ../../src/gcc/tree-inline.c:4653 0xb0ba06 gimple_expand_calls_inline ../../src/gcc/tree-inline.c:4791 0xb0ba06 optimize_inline_calls(tree_node*) ../../src/gcc/tree-inline.c:4931 0xff06db early_inliner(function*) ../../src/gcc/ipa-inline.c:2689 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <file:///usr/share/doc/gcc-5/README.Bugs> for instructions. ================================================================= /usr/bin/c++ -v Using built-in specs. COLLECT_GCC=/usr/bin/c++ COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: /build/gcc/src/gcc-5-20160209/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --enable-libmpx --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --disable-multilib --disable-werror --enable-checking=release Thread model: posix gcc version 5.3.0 (GCC) /usr/bin/c++ -mavx2 -O2 -c simd.cpp simd.cpp:27:41: warning: always_inline function might not be inlinable [-Wattributes] __attribute__((__always_inline__)) void inlineFunc(Tx hx[]) { ^ simd.cpp: In function ‘void FooBarFunc()’: simd.cpp:34:19: internal compiler error: in make_ssa_name_fn, at tree-ssanames.c:151 inlineFunc (adp); ^ Please submit a full bug report, with preprocessed source if appropriate. See <https://bugs.archlinux.org/> for instructions. ================================================================= g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/home/matthias/local/libexec/gcc/x86_64-pc-linux-gnu/6.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../configure --prefix=/usr --disable-multilib --disable-bootstrap --with-system-zlib --prefix=/home/matthias/local --enable-languages=c,c++,lto --no-create --no-recursion Thread model: posix gcc version 6.0.0 20160321 (experimental) (GCC) g++ -mavx2 -O2 -c simd.cpp simd.cpp:27:41: warning: always_inline function might not be inlinable [-Wattributes] __attribute__((__always_inline__)) void inlineFunc(Tx hx[]) { ^~~~~~~~~~ simd.cpp: In function ‘void FooBarFunc()’: simd.cpp:34:19: internal compiler error: in make_ssa_name_fn, at tree-ssanames.c:266 inlineFunc (adp); ^ 0xf2da17 make_ssa_name_fn(function*, tree_node*, gimple*) ../../gcc/tree-ssanames.c:263 0xda3684 make_ssa_name ../../gcc/tree-ssanames.h:111 0xda3684 remap_ssa_name ../../gcc/tree-inline.c:238 0xda9fd7 remap_gimple_op_r ../../gcc/tree-inline.c:867 0xfd0142 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, default_hash_traits<tree_node*> >*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, default_hash_traits<tree_node*> >*)) ../../gcc/tree.c:11531 0xabf73b walk_gimple_op(gimple*, tree_node* (*)(tree_node**, int*, void*), walk_stmt_info*) ../../gcc/gimple-walk.c:266 0xda450c remap_gimple_stmt ../../gcc/tree-inline.c:1713 0xda56fe copy_bb ../../gcc/tree-inline.c:1771 0xda6bb8 copy_cfg_body ../../gcc/tree-inline.c:2725 0xda6bb8 copy_body ../../gcc/tree-inline.c:2965 0xdac4c0 expand_call_inline ../../gcc/tree-inline.c:4664 0xdac4c0 gimple_expand_calls_inline ../../gcc/tree-inline.c:4804 0xdac4c0 optimize_inline_calls(tree_node*) ../../gcc/tree-inline.c:4944 0x1418e8c early_inliner(function*) ../../gcc/ipa-inline.c:2695 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions.
Confirmed. 264 gcc_assert (TREE_CODE (var) == VAR_DECL 265 || TREE_CODE (var) == PARM_DECL 266 || TREE_CODE (var) == RESULT_DECL 267 || (TYPE_P (var) && is_gimple_reg_type (var))); 268 (gdb) p var $1 = <record_type 0x7ffff5137738 SIMD>
einline produces the broken SSA name initially (in some way). Created by #2 0x0000000000da59f9 in gimple_regimplify_operands (stmt= <gimple_call 0x7ffff515bab0>, gsi_p=0x7fffffff8c50) at /space/rguenther/src/svn/trunk/gcc/gimplify-me.c:303 303 temp = make_ssa_name (temp); (gdb) l 298 } 299 if (need_temp) 300 { 301 tree temp = create_tmp_reg (TREE_TYPE (lhs)); 302 if (gimple_in_ssa_p (cfun)) 303 temp = make_ssa_name (temp); 304 gimple_set_lhs (stmt, temp); 305 post_stmt = gimple_build_assign (lhs, temp); (gdb) p debug_gimple_stmt (stmt) # .MEM = VDEF <.MEM> MEM[(struct SIMD *)_1] = SIMD::operator* (&hx, hy); the code is really weird. if (is_gimple_reg_type (TREE_TYPE (lhs))) need_temp = true; else if (TYPE_MODE (TREE_TYPE (lhs)) != BLKmode) { if (is_gimple_call (stmt)) { tree fndecl = gimple_call_fndecl (stmt); if (!aggregate_value_p (TREE_TYPE (lhs), fndecl) && !(fndecl && DECL_RESULT (fndecl) && DECL_BY_REFERENCE (DECL_RESULT (fndecl)))) need_temp = true; } else need_temp = true; } the is_gimple_reg_type case should be the only thing necessary. But the whole function is a totally weird beast. I'm not going to touch that but try papering over this mess in some way (probably how this shit evolved...). So instead of the above we'll get re-gimplified D.27340 = SIMD::operator* (&hx, hy); MEM[(struct SIMD *)_1] = D.27340; Index: gcc/gimplify-me.c =================================================================== --- gcc/gimplify-me.c (revision 234705) +++ gcc/gimplify-me.c (working copy) @@ -299,7 +299,8 @@ gimple_regimplify_operands (gimple *stmt if (need_temp) { tree temp = create_tmp_reg (TREE_TYPE (lhs)); - if (gimple_in_ssa_p (cfun)) + if (gimple_in_ssa_p (cfun) + && is_gimple_reg_type (TREE_TYPE (lhs))) temp = make_ssa_name (temp); gimple_set_lhs (stmt, temp); post_stmt = gimple_build_assign (lhs, temp);
The function needs to deal with cases where e.g. DECL_VALUE_EXPR is added to various VAR_DECLs and the IL needs to be updated accordingtly. It is mostly used by OpenMP lowering, and that is done not in SSA form, so that is why most of its testcase coverage is without SSA. Anyway, for the testcase, it would be perhaps better to use typedef double v4df __attribute__((vector_size (32))); and use v4df instead of __m256d (and immintrin.h include). Is it inentional that hx and hy are uninitialized and y is unused? Shouldn't hx be initialized to Value().data and hy to y.Value().data ?
This testcase is just a very striped-down version of the actual code to reproduce the error, so it may seem useless at some spots, like the missing initialization. We already have a workaround by adding additional __attribute__((__always_inline__)) to the methods of SIMD, in this sense it's no critical bug. This code is part of a cross-platform project. We are including immintrin.h since it is supplied by all used compilers. I am not sure how typedef double v4df __attribute__((vector_size (32))); behaves on others, but we will give it a try. Thanks, Matthias
I haven't been talking on what you should be using in your project, but rather what testcase we want to include in GCC sources. And there the immintrin.h dependency IMHO is unnecessary etc.
Oh, now I get it, sorry for the misunderstanding.
Author: rguenth Date: Tue Apr 5 08:05:06 2016 New Revision: 234738 URL: https://gcc.gnu.org/viewcvs?rev=234738&root=gcc&view=rev Log: 2016-04-05 Richard Biener <rguenther@suse.de> PR middle-end/70499 * gimplify-me.c (gimple_regimplify_operands): Do not rewrite non-register type temporaries into SSA. * g++.dg/torture/pr70499.C: New testcase. Added: trunk/gcc/testsuite/g++.dg/torture/pr70499.C Modified: trunk/gcc/ChangeLog trunk/gcc/gimplify-me.c trunk/gcc/testsuite/ChangeLog
Fixed on trunk sofar.
Richi Can the bug be marked as resolved? Or at least please update Known to work.
Fixed.