We noticed that adding 'const' qualifier to function arguments marked with simd declare pragma leads to issue ICE on attached test-case. Test is compiled successfully if 'const' was deleted. To reproduce failure the following command line options are needed: -O1 -m64 test.cpp -c -fopenmp.
Created attachment 32585 [details] C++ test-case to reproduce Need to be compiled with -O1 -m64 test.cpp -c -fopenmp options to reproduce ICE.
Confirmed. Some out-of-SSA issue it seems.
I'd like to notice that this is test with using 'omp declare simd' pragma and issue is rather related to its support in gcc.
Created attachment 32618 [details] gcc49-pr60823.patch Untested work in progress patch. We weren't adjusting PHIs (arguments or result vars), but what the code was doing was simply wrong anyway whenever there would be an overlap between SSA_NAMEs refering to the same PARM_DECL. This patch should fix that, and contains testcases for both ice-on-valid and wrong-code without the patch, but I'll still need to look at handling of addressable parameters that are requested to be vectorized plus write testcases for that.
Created attachment 32624 [details] gcc49-pr60823.patch Updated (still untested) patch.
Author: jakub Date: Tue Apr 22 10:21:32 2014 New Revision: 209616 URL: http://gcc.gnu.org/viewcvs?rev=209616&root=gcc&view=rev Log: PR tree-optimization/60823 * omp-low.c (ipa_simd_modify_function_body): Go through all SSA_NAMEs and for those refering to vector arguments which are going to be replaced adjust SSA_NAME_VAR and, if it is a default definition, change it into a non-default definition assigned at the beginning of function from new_decl. (ipa_simd_modify_stmt_ops): Rewritten. * tree-dfa.c (set_ssa_default_def): When removing default def, check for NULL loc instead of NULL *loc. * c-c++-common/gomp/pr60823-1.c: New test. * c-c++-common/gomp/pr60823-2.c: New test. * c-c++-common/gomp/pr60823-3.c: New test. Added: trunk/gcc/testsuite/c-c++-common/gomp/pr60823-1.c trunk/gcc/testsuite/c-c++-common/gomp/pr60823-2.c trunk/gcc/testsuite/c-c++-common/gomp/pr60823-3.c Modified: trunk/gcc/ChangeLog trunk/gcc/omp-low.c trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-dfa.c
Author: jakub Date: Tue Apr 22 13:16:31 2014 New Revision: 209626 URL: http://gcc.gnu.org/viewcvs?rev=209626&root=gcc&view=rev Log: PR tree-optimization/60823 * omp-low.c (ipa_simd_modify_function_body): Go through all SSA_NAMEs and for those refering to vector arguments which are going to be replaced adjust SSA_NAME_VAR and, if it is a default definition, change it into a non-default definition assigned at the beginning of function from new_decl. (ipa_simd_modify_stmt_ops): Rewritten. * tree-dfa.c (set_ssa_default_def): When removing default def, check for NULL loc instead of NULL *loc. * c-c++-common/gomp/pr60823-1.c: New test. * c-c++-common/gomp/pr60823-2.c: New test. * c-c++-common/gomp/pr60823-3.c: New test. Added: branches/gcc-4_9-branch/gcc/testsuite/c-c++-common/gomp/pr60823-1.c branches/gcc-4_9-branch/gcc/testsuite/c-c++-common/gomp/pr60823-2.c branches/gcc-4_9-branch/gcc/testsuite/c-c++-common/gomp/pr60823-3.c Modified: branches/gcc-4_9-branch/gcc/ChangeLog branches/gcc-4_9-branch/gcc/omp-low.c branches/gcc-4_9-branch/gcc/testsuite/ChangeLog branches/gcc-4_9-branch/gcc/tree-dfa.c
Fixed.
sorry fro squatting this thread: I noticed that compiling the test case for haswell it does not make use of umm registers c++ -std=c++11 -Ofast -fopenmp -S simdCloning.cc -march=haswell; grep ymm simdCloning.s vmovupd %ymm0, -80(%rbp) vmovupd %ymm1, -48(%rbp) vmovapd %ymm0, -80(%rbp) vmovapd %ymm1, -48(%rbp) vmovdqa -112(%rbp), %ymm0 changing int to long long does not make any effect... same changing double to float and widening the simdlen to 8. any "good" reason? should I open a new bug report (tree-optimization I suppose)?
(In reply to vincenzo Innocente from comment #9) > sorry fro squatting this thread: > I noticed that compiling the test case for haswell it does not make use of > umm registers > c++ -std=c++11 -Ofast -fopenmp -S simdCloning.cc -march=haswell; grep ymm > simdCloning.s > vmovupd %ymm0, -80(%rbp) > vmovupd %ymm1, -48(%rbp) > vmovapd %ymm0, -80(%rbp) > vmovapd %ymm1, -48(%rbp) > vmovdqa -112(%rbp), %ymm0 > > changing int to long long does not make any effect... > same changing double to float and widening the simdlen to 8. > > any "good" reason? > should I open a new bug report (tree-optimization I suppose)? If you look into the -fdump-tree-vect-details dump, you'll see it is not vectorized at all, I guess the primary issue is the nested loop in there, I guess you were expecting that the 4 or 8 outer loop (the compiler added) iterations will be vectorized and just get execute the inner loop which has fixed number of iterations and doesn't have any conditionals. But that is not what our vectorizer supports unfortunately, for nested loops it instead attempts to vectorize consecutive iterations of the inner loop (which doesn't of course work here, because the iterations depend on each other).