https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127863
Bug ID: 127863
Summary: [OpenACC] ICE: tree check: expected ssa_name, have
integer_cst in find_reduc_addr, at
tree-parloops.cc:3275
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: ice-on-valid-code, openacc
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: dohanam2 at illinois dot edu
Target Milestone: ---
The following OpenACC kernels region, a sum reduction whose accumulator starts
at a constant, makes cc1 crash in pass parloops with -fopenacc and any of -O1,
-O2 or -O3 (the same ICE at each level).
$ cat t.c
unsigned u[1024];
void f(unsigned *r) {
#pragma acc kernels copyin(u) copyout(r[0:1])
{
unsigned s = 0;
for (int i = 0; i < 1024; i++) s += u[i];
r[0] = s;
}
}
$ gcc -O2 -fopenacc -c t.c
during GIMPLE pass: parloops
t.c: In function 'f._omp_fn.0':
t.c:9:1: internal compiler error: tree check: expected ssa_name, have
integer_cst in find_reduc_addr, at tree-parloops.cc:3275
9 | }
| ^
0x284c3fb internal_error(char const*, ...)
../../gcc/diagnostic-global-context.cc:787
0x8fd14c tree_check_failed(tree_node const*, char const*, int, char const*,
...)
../../gcc/tree.cc:9247
0x8a8c0e tree_check(tree_node*, char const*, int, char const*, tree_code)
../../gcc/tree.h:3837
0x8a8c0e find_reduc_addr
../../gcc/tree-parloops.cc:3275
0x8a8c0e try_create_reduction_list
../../gcc/tree-parloops.cc:3426
0x8a8c0e parallelize_loops
../../gcc/tree-parloops.cc:3931
0x12fddbb execute
../../gcc/tree-parloops.cc:4051
0x12fddbb execute
../../gcc/tree-parloops.cc:4030
[the cc1 command line, which only names local build paths, is left out here]
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
A build without tree checking segfaults in find_reduc_addr instead ("internal
compiler error: Segmentation fault").
If the accumulator starts from a value loaded from outside the region (for
example "unsigned s = k;" with k a parameter of f), it compiles fine.
find_reduc_addr seems to pass the preheader PHI argument
(PHI_ARG_DEF_FROM_EDGE) to SSA_NAME_DEF_STMT without checking that it is an
SSA_NAME; here it is the constant 0.
gcc version 17.0.0 20261008 (experimental), configured with
--enable-checking=yes,extra --enable-languages=c; it also reproduces at trunk
e887376de60a.
Found with an LLM-based testing tool; the triage and this text were prepared
with the help of Claude (an AI model). The outputs above are copied unedited
from runs of the commands shown (except the omitted cc1 line), on trunk
20261008, and the ICE was re-checked on trunk e887376de60a.