Bug 88553 - ICE: tree check: expected ssa_name, have var_decl in SSA_VAL, at tree-ssa-sccvn.c:461
Summary: ICE: tree check: expected ssa_name, have var_decl in SSA_VAL, at tree-ssa-scc...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 9.0
: P3 normal
Target Milestone: 7.5
Assignee: Jakub Jelinek
URL:
Keywords: ice-on-valid-code, openmp
Depends on:
Blocks:
 
Reported: 2018-12-19 16:41 UTC by Arseny Solokha
Modified: 2019-08-30 13:41 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-12-19 00:00:00


Attachments
gcc9-pr88553.patch (1.11 KB, patch)
2018-12-21 15:53 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Arseny Solokha 2018-12-19 16:41:42 UTC
gcc-9.0.0-alpha20181111 snapshot (r266019) ICEs when compiling gcc/testsuite/gcc.dg/gomp/pr81768-2.c at any optimization level and w/ -fopenmp -ftree-loop-vectorize -fwrapv:

% gcc-9.0.0-alpha20181216 -O1 -fopenmp -ftree-loop-vectorize -fwrapv -c gcc/testsuite/gcc.dg/gomp/pr81768-2.c
during GIMPLE pass: ifcvt
gcc/testsuite/gcc.dg/gomp/pr81768-2.c: In function 'foo._omp_fn.1':
gcc/testsuite/gcc.dg/gomp/pr81768-2.c:10:9: internal compiler error: tree check: expected ssa_name, have var_decl in SSA_VAL, at tree-ssa-sccvn.c:462
   10 | #pragma omp target parallel for schedule(static, 32) collapse(3)
      |         ^~~
0x6dd283 tree_check_failed(tree_node const*, char const*, int, char const*, ...)
	/var/tmp/portage/sys-devel/gcc-9.0.0_alpha20181216/work/gcc-9-20181216/gcc/tree.c:9757
0x6bddf3 tree_check(tree_node*, char const*, int, char const*, tree_code)
	/var/tmp/portage/sys-devel/gcc-9.0.0_alpha20181216/work/gcc-9-20181216/gcc/tree.h:3157
0x6bddf3 SSA_VAL(tree_node*, bool*)
	/var/tmp/portage/sys-devel/gcc-9.0.0_alpha20181216/work/gcc-9-20181216/gcc/tree-ssa-sccvn.c:462
0x6bddf3 vuse_ssa_val
	/var/tmp/portage/sys-devel/gcc-9.0.0_alpha20181216/work/gcc-9-20181216/gcc/tree-ssa-sccvn.c:480
0x6bddf3 vn_reference_lookup(tree_node*, tree_node*, vn_lookup_kind, vn_reference_s**, bool)
	/var/tmp/portage/sys-devel/gcc-9.0.0_alpha20181216/work/gcc-9-20181216/gcc/tree-ssa-sccvn.c:2626
0xeb9301 visit_reference_op_load
	/var/tmp/portage/sys-devel/gcc-9.0.0_alpha20181216/work/gcc-9-20181216/gcc/tree-ssa-sccvn.c:3979
0xeb9301 visit_stmt
	/var/tmp/portage/sys-devel/gcc-9.0.0_alpha20181216/work/gcc-9-20181216/gcc/tree-ssa-sccvn.c:4397
0xeba68d process_bb
	/var/tmp/portage/sys-devel/gcc-9.0.0_alpha20181216/work/gcc-9-20181216/gcc/tree-ssa-sccvn.c:6047
0xebbe1d do_rpo_vn
	/var/tmp/portage/sys-devel/gcc-9.0.0_alpha20181216/work/gcc-9-20181216/gcc/tree-ssa-sccvn.c:6654
0xebd008 do_rpo_vn(function*, edge_def*, bitmap_head*)
	/var/tmp/portage/sys-devel/gcc-9.0.0_alpha20181216/work/gcc-9-20181216/gcc/tree-ssa-sccvn.c:6743
0xd7af41 tree_if_conversion(loop*)
	/var/tmp/portage/sys-devel/gcc-9.0.0_alpha20181216/work/gcc-9-20181216/gcc/tree-if-conv.c:3066
0xd7c626 execute
	/var/tmp/portage/sys-devel/gcc-9.0.0_alpha20181216/work/gcc-9-20181216/gcc/tree-if-conv.c:3142
0xd7c626 execute
	/var/tmp/portage/sys-devel/gcc-9.0.0_alpha20181216/work/gcc-9-20181216/gcc/tree-if-conv.c:3130

It was initially reported in PR85594 comment 2, but that made little sense as it's most likely an unrelated issue manifesting itself at a different level of the compilation pipeline.
Comment 1 Richard Biener 2018-12-19 17:33:26 UTC
Confirmed.  GCC 8 ICEs with

during GIMPLE pass: ifcvt
pr81768-2.c: In function ‘foo._omp_fn.1’:
pr81768-2.c:10:9: internal compiler error: in execute_todo, at passes.c:2043
 #pragma omp target parallel for schedule(static, 32) collapse(3)
         ^~~
0xec47fc execute_todo
        /space/rguenther/src/svn/gcc-8-branch/gcc/passes.c:2043
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

GCC 7 with

pr81768-2.c: In function ‘foo._omp_fn.1’:
pr81768-2.c:10:9: internal compiler error: in make_decl_rtl, at varasm.c:1310
 #pragma omp target parallel for schedule(static, 32) collapse(3)
         ^~~
0x12debba make_decl_rtl(tree_node*)
        /space/rguenther/src/svn/gcc-7-branch/gcc/varasm.c:1306
0xac61f0 expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool)
        /space/rguenther/src/svn/gcc-7-branch/gcc/expr.c:9873
0xabeec1 expand_expr_real(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool)
        /space/rguenther/src/svn/gcc-7-branch/gcc/expr.c:8141
0xaa5945 expand_expr

all probably the same underlying issue of if-conversion mucking up SSA form
in unexpected ways.
Comment 2 Richard Biener 2018-12-19 17:43:25 UTC
OK, so this is a DECL_VALUE_EXPR leaking from gimplifying a BB predicate
using &b[0][0][0] < k_57 and that getting gimplified to

_120 = .omp_data_i->b;
_121 = &*_120[0][0][0];
k_19 = _121 < k_57 ? k_57 : _23;

which means sth forgot to re-gimplify this address in the first place.

.omplow has

                    #pragma omp for schedule(static,32) collapse(3) nowait private(i)
                    for (i = &b[0][0][0]; i < &b[0][0][10]; i = i + 4)
                      for (j = &b[0][15][0]; j > &b[0][0][0]; j = j + 18446744073709551576)
                        for (k = &b[0][0][10]; k > &b[0][0][0]; k = k + 18446744073709551612)
                    D.2063 = .omp_data_i->b;
                    D.2064 = &*D.2063[0][0][0];
                    D.2039 = i - D.2064;
                    D.2040 = D.2039 /[ex] 4;

is lowering already missed here?

Jakub, you are more familiar with this - as said, it's latent everywhere.
Comment 3 Arseny Solokha 2018-12-20 00:07:28 UTC
(In reply to Richard Biener from comment #1)
> GCC 7 with
> 
> pr81768-2.c: In function ‘foo._omp_fn.1’:
> pr81768-2.c:10:9: internal compiler error: in make_decl_rtl, at varasm.c:1310

One gets ICE in make_decl_rtl on all branches by simply omitting -ftree-loop-vectorize, as was originally reported in PR85594.
Comment 4 Jakub Jelinek 2018-12-21 15:53:31 UTC
Created attachment 45280 [details]
gcc9-pr88553.patch

Untested fix.
Comment 5 Jakub Jelinek 2018-12-21 19:17:46 UTC
Author: jakub
Date: Fri Dec 21 19:17:13 2018
New Revision: 267339

URL: https://gcc.gnu.org/viewcvs?rev=267339&root=gcc&view=rev
Log:
	PR middle-end/85594
	PR middle-end/88553
	* omp-expand.c (extract_omp_for_update_vars): Regimplify the condition
	if needed.
	(expand_omp_for_generic): Don't clobber t temporary for ordered loops.

	* gcc.dg/gomp/pr85594.c: New test.
	* gcc.dg/gomp/pr88553.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/gomp/pr85594.c
    trunk/gcc/testsuite/gcc.dg/gomp/pr88553.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/omp-expand.c
    trunk/gcc/testsuite/ChangeLog
Comment 6 Jakub Jelinek 2018-12-21 19:23:22 UTC
Fixed on the trunk, will backport at some point.
Comment 7 Jakub Jelinek 2019-01-08 10:31:47 UTC
Author: jakub
Date: Tue Jan  8 10:30:45 2019
New Revision: 267716

URL: https://gcc.gnu.org/viewcvs?rev=267716&root=gcc&view=rev
Log:
	Backported from mainline
	2018-12-21  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/85594
	PR middle-end/88553
	* omp-expand.c (extract_omp_for_update_vars): Regimplify the condition
	if needed.
	(expand_omp_for_generic): Don't clobber t temporary for ordered loops.

	* gcc.dg/gomp/pr85594.c: New test.
	* gcc.dg/gomp/pr88553.c: New test.

Added:
    branches/gcc-8-branch/gcc/testsuite/gcc.dg/gomp/pr85594.c
    branches/gcc-8-branch/gcc/testsuite/gcc.dg/gomp/pr88553.c
Modified:
    branches/gcc-8-branch/gcc/ChangeLog
    branches/gcc-8-branch/gcc/omp-expand.c
    branches/gcc-8-branch/gcc/testsuite/ChangeLog
Comment 8 Jakub Jelinek 2019-01-08 10:50:33 UTC
Fixed for 8.3+ too.
Comment 9 Jakub Jelinek 2019-08-30 11:23:48 UTC
Author: jakub
Date: Fri Aug 30 11:23:16 2019
New Revision: 275082

URL: https://gcc.gnu.org/viewcvs?rev=275082&root=gcc&view=rev
Log:
	Backported from mainline
	2018-12-21  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/85594
	PR middle-end/88553
	* omp-expand.c (extract_omp_for_update_vars): Regimplify the condition
	if needed.
	(expand_omp_for_generic): Don't clobber t temporary for ordered loops.

	* gcc.dg/gomp/pr85594.c: New test.
	* gcc.dg/gomp/pr88553.c: New test.

Added:
    branches/gcc-7-branch/gcc/testsuite/gcc.dg/gomp/pr85594.c
    branches/gcc-7-branch/gcc/testsuite/gcc.dg/gomp/pr88553.c
Modified:
    branches/gcc-7-branch/gcc/ChangeLog
    branches/gcc-7-branch/gcc/omp-expand.c
    branches/gcc-7-branch/gcc/testsuite/ChangeLog
Comment 10 Jakub Jelinek 2019-08-30 13:41:25 UTC
Fixed.