Bug 60823 - [4.9/4.10 Regression] ICE in gimple_expand_cfg, at cfgexpand.c:5644
Summary: [4.9/4.10 Regression] ICE in gimple_expand_cfg, at cfgexpand.c:5644
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.9.0
: P3 normal
Target Milestone: 4.9.1
Assignee: Jakub Jelinek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-11 14:08 UTC by Yuri Rumyantsev
Modified: 2018-11-26 03:17 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 4.10.0, 4.8.3, 4.9.1
Known to fail: 4.9.0
Last reconfirmed: 2014-04-14 00:00:00


Attachments
C++ test-case to reproduce (225 bytes, text/plain)
2014-04-11 14:11 UTC, Yuri Rumyantsev
Details
gcc49-pr60823.patch (1.56 KB, patch)
2014-04-16 18:32 UTC, Jakub Jelinek
Details | Diff
gcc49-pr60823.patch (2.71 KB, patch)
2014-04-17 14:46 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yuri Rumyantsev 2014-04-11 14:08:20 UTC
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.
Comment 1 Yuri Rumyantsev 2014-04-11 14:11:31 UTC
Created attachment 32585 [details]
C++ test-case to reproduce

Need to be compiled with -O1  -m64  test.cpp -c -fopenmp options to reproduce ICE.
Comment 2 Richard Biener 2014-04-14 09:49:18 UTC
Confirmed.  Some out-of-SSA issue it seems.
Comment 3 Yuri Rumyantsev 2014-04-15 12:52:34 UTC
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.
Comment 4 Jakub Jelinek 2014-04-16 18:32:29 UTC
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.
Comment 5 Jakub Jelinek 2014-04-17 14:46:17 UTC
Created attachment 32624 [details]
gcc49-pr60823.patch

Updated (still untested) patch.
Comment 6 Jakub Jelinek 2014-04-22 10:22:04 UTC
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
Comment 7 Jakub Jelinek 2014-04-22 13:17:03 UTC
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
Comment 8 Jakub Jelinek 2014-04-22 13:17:51 UTC
Fixed.
Comment 9 vincenzo Innocente 2014-05-19 07:04:39 UTC
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)?
Comment 10 Jakub Jelinek 2014-05-19 07:34:40 UTC
(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).