public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/105975] New: OpenMP/nvptx offloading: 'internal compiler error: in maybe_legitimize_operand, at optabs.cc:7785'
@ 2022-06-14 14:40 tschwinge at gcc dot gnu.org
2022-06-14 20:08 ` [Bug target/105975] " rsandifo at gcc dot gnu.org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: tschwinge at gcc dot gnu.org @ 2022-06-14 14:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105975
Bug ID: 105975
Summary: OpenMP/nvptx offloading: 'internal compiler error: in
maybe_legitimize_operand, at optabs.cc:7785'
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Keywords: openmp
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: tschwinge at gcc dot gnu.org
CC: jakub at gcc dot gnu.org, rsandifo at gcc dot gnu.org,
vries at gcc dot gnu.org
Target Milestone: ---
Target: nvptx
The recent commit r13-1068-g1d205dbac1e1754c01c22a31bd1688126545401e "Factor
out common internal-fn idiom" causes a class of ICEs in OpenMP/nvptx offloading
compilation: 'during RTL pass: expand', 'internal compiler error: in
maybe_legitimize_operand, at optabs.cc:7785', seen for a lot of libgomp
OpenMP/nvptx offloading test cases (with '-O1' and higher).
0xb1b0b3 maybe_legitimize_operand
[...]/source-gcc/gcc/optabs.cc:7785
0xb1b0b3 maybe_legitimize_operands(insn_code, unsigned int, unsigned int,
expand_operand*)
[...]/source-gcc/gcc/optabs.cc:7936
0xb1b139 maybe_gen_insn(insn_code, unsigned int, expand_operand*)
[...]/source-gcc/gcc/optabs.cc:7955
0xb1a8b8 maybe_expand_insn(insn_code, unsigned int, expand_operand*)
[...]/source-gcc/gcc/optabs.cc:7998
0xb1a8b8 expand_insn(insn_code, unsigned int, expand_operand*)
[...]/source-gcc/gcc/optabs.cc:8029
0x95dcb3 expand_fn_using_insn
[...]/source-gcc/gcc/internal-fn.cc:193
0x6d3ee7 expand_call_stmt
[...]/source-gcc/gcc/cfgexpand.cc:2737
0x6d3ee7 expand_gimple_stmt_1
[...]/source-gcc/gcc/cfgexpand.cc:3869
For extra entertainment: when running with '-wrapper "$GDB",-q,--args', we get
'[Inferior 1 (process [...]) exited normally]'... (Maybe Valgrind could help?
Unless someone directly pinpoints the issue, of course.)
I've not yet determined whether it's a latent problem just exposed by this
commit, or whether the commit itself has an issue. It's not magically fixed by
the related subsequent commit
r13-1069-gf8baf4004ef965ce7a9edf6d2f5eb99adb15803a "Add a general mapping from
internal fns to target insns".
'gcc/internal-fn.cc':
193 expand_insn (icode, opno, ops);
'gcc/optabs.cc':
8026 expand_insn (enum insn_code icode, unsigned int nops,
8027 class expand_operand *ops)
8028 {
8029 if (!maybe_expand_insn (icode, nops, ops))
7995 maybe_expand_insn (enum insn_code icode, unsigned int nops,
7996 class expand_operand *ops)
7997 {
7998 rtx_insn *pat = maybe_gen_insn (icode, nops, ops);
7951 maybe_gen_insn (enum insn_code icode, unsigned int nops,
7952 class expand_operand *ops)
7953 {
7954 gcc_assert (nops == (unsigned int) insn_data[(int)
icode].n_generator_args);
7955 if (!maybe_legitimize_operands (icode, 0, nops, ops))
7935 /* Otherwise try legitimizing the operand on its own. */
7936 if (j == i && !maybe_legitimize_operand (icode, opno + i,
&ops[i]))
7784 case EXPAND_OUTPUT:
7785 gcc_assert (mode != VOIDmode);
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/105975] OpenMP/nvptx offloading: 'internal compiler error: in maybe_legitimize_operand, at optabs.cc:7785'
2022-06-14 14:40 [Bug target/105975] New: OpenMP/nvptx offloading: 'internal compiler error: in maybe_legitimize_operand, at optabs.cc:7785' tschwinge at gcc dot gnu.org
@ 2022-06-14 20:08 ` rsandifo at gcc dot gnu.org
2022-06-15 8:49 ` tschwinge at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: rsandifo at gcc dot gnu.org @ 2022-06-14 20:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105975
--- Comment #1 from rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> ---
Could you point to a specific test and give command-line arguments?
I'm not set up to do an nvptx test run.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/105975] OpenMP/nvptx offloading: 'internal compiler error: in maybe_legitimize_operand, at optabs.cc:7785'
2022-06-14 14:40 [Bug target/105975] New: OpenMP/nvptx offloading: 'internal compiler error: in maybe_legitimize_operand, at optabs.cc:7785' tschwinge at gcc dot gnu.org
2022-06-14 20:08 ` [Bug target/105975] " rsandifo at gcc dot gnu.org
@ 2022-06-15 8:49 ` tschwinge at gcc dot gnu.org
2022-06-15 8:51 ` tschwinge at gcc dot gnu.org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: tschwinge at gcc dot gnu.org @ 2022-06-15 8:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105975
--- Comment #2 from Thomas Schwinge <tschwinge at gcc dot gnu.org> ---
Created attachment 53140
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53140&action=edit
'a-for-11.o.xz'
With commit 1d205dbac1e1754c01c22a31bd1688126545401e "Factor out common
internal-fn idiom" sources, I've run such an OpenMP/nvptx offloading
compilation ('libgomp.c-c++-common/for-11.c', '-O1') with '-v -save-temps', and
we see:
[...]
/home/thomas/tmp/source/gcc/build/trace-slim-omp/build-gcc-offload-nvptx-none/gcc/lto1
-quiet -dumpbase ./a.xnvptx-none.mkoffload -m64 -mgomp -O1 -version
-fno-openacc -fno-pie -fcf-protection=none -foffload-abi=lp64 -fopenmp
@./a.xnvptx-none.mkoffload.args.0 -o ./a.xnvptx-none.mkoffload.s
[...]
during RTL pass: expand
source-gcc/libgomp/testsuite/libgomp.c-c++-common/for-2.h: In function
‘f20_tpf_simd_static._omp_fn.1’:
source-gcc/libgomp/testsuite/libgomp.c-c++-common/for-2.h:343:9: internal
compiler error: in maybe_legitimize_operand, at optabs.cc:7785
[...]
$ cat < a.xnvptx-none.mkoffload.args.0
a-for-11.o
If you now build a nvptx offloading compiler (same commit
1d205dbac1e1754c01c22a31bd1688126545401e sources):
$ ../source-gcc/configure --target=nvptx-none
--enable-as-accelerator-for=x86_64-pc-linux-gnu --enable-languages=lto
--enable-checking=yes,extra,rtl
$ make -j16 all-gcc
..., you ought to be able to reproduce the ICE (using the 'a-for-11.o' I've
attached to this PR, 'xz'-compressed):
$ gcc/lto1 -quiet -dumpbase ./a.xnvptx-none.mkoffload -m64 -mgomp -O1
-version -fno-openacc -fno-pie -fcf-protection=none -foffload-abi=lp64 -fopenmp
a-for-11.o -o ./a.xnvptx-none.mkoffload.s
[...]
during RTL pass: expand
../source-gcc/libgomp/testsuite/libgomp.c-c++-common/for-2.h: In function
‘f20_tpf_simd_static._omp_fn.1’:
../source-gcc/libgomp/testsuite/libgomp.c-c++-common/for-2.h:343:9:
internal compiler error: in maybe_legitimize_operand, at optabs.cc:7785
[...]
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/105975] OpenMP/nvptx offloading: 'internal compiler error: in maybe_legitimize_operand, at optabs.cc:7785'
2022-06-14 14:40 [Bug target/105975] New: OpenMP/nvptx offloading: 'internal compiler error: in maybe_legitimize_operand, at optabs.cc:7785' tschwinge at gcc dot gnu.org
2022-06-14 20:08 ` [Bug target/105975] " rsandifo at gcc dot gnu.org
2022-06-15 8:49 ` tschwinge at gcc dot gnu.org
@ 2022-06-15 8:51 ` tschwinge at gcc dot gnu.org
2022-06-15 11:01 ` rsandifo at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: tschwinge at gcc dot gnu.org @ 2022-06-15 8:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105975
--- Comment #3 from Thomas Schwinge <tschwinge at gcc dot gnu.org> ---
Created attachment 53141
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53141&action=edit
'a.xnvptx-none.mkoffload.s.xz'
For cross-checking: if I now temporarily 'git revert
1d205dbac1e1754c01c22a31bd1688126545401e', and rebuilt things, I get the same
'a-for-11.o' file (with just some randomness in '.section' names; different
issue), and the nvptx 'gcc/lto1' command produces 'a.xnvptx-none.mkoffload.s'
as attached ('xz'-compressed).
(I'll soon be off of work for a few days.)
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/105975] OpenMP/nvptx offloading: 'internal compiler error: in maybe_legitimize_operand, at optabs.cc:7785'
2022-06-14 14:40 [Bug target/105975] New: OpenMP/nvptx offloading: 'internal compiler error: in maybe_legitimize_operand, at optabs.cc:7785' tschwinge at gcc dot gnu.org
` (2 preceding siblings ...)
2022-06-15 8:51 ` tschwinge at gcc dot gnu.org
@ 2022-06-15 11:01 ` rsandifo at gcc dot gnu.org
2022-06-15 16:40 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: rsandifo at gcc dot gnu.org @ 2022-06-15 11:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105975
rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |rsandifo at gcc dot gnu.org
Last reconfirmed| |2022-06-15
--- Comment #4 from rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> ---
Thanks for the reproducer.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/105975] OpenMP/nvptx offloading: 'internal compiler error: in maybe_legitimize_operand, at optabs.cc:7785'
2022-06-14 14:40 [Bug target/105975] New: OpenMP/nvptx offloading: 'internal compiler error: in maybe_legitimize_operand, at optabs.cc:7785' tschwinge at gcc dot gnu.org
` (3 preceding siblings ...)
2022-06-15 11:01 ` rsandifo at gcc dot gnu.org
@ 2022-06-15 16:40 ` cvs-commit at gcc dot gnu.org
2022-06-15 16:42 ` rsandifo at gcc dot gnu.org
2022-06-15 21:04 ` tschwinge at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-06-15 16:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105975
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Richard Sandiford <rsandifo@gcc.gnu.org>:
https://gcc.gnu.org/g:9d2fe6d427b37755410bb4eb4ecce8382f2ebfc5
commit r13-1111-g9d2fe6d427b37755410bb4eb4ecce8382f2ebfc5
Author: Richard Sandiford <richard.sandiford@arm.com>
Date: Wed Jun 15 17:40:09 2022 +0100
Revert recent internal-fn changes [PR105975]
The recent internal-fn âclean-upsâ triggered problems on nvptx
because some of the omp_simt_* patterns had modeless operands.
I wondered about adapting expand_fn_using_insn to cope with that,
but then the problem becomes: what should the mode of operand 0
be when there is no lhs? The answer depends on the target insn.
For GOMP_SIMT_ENTER_ALLOC the answer was: use Pmode.
For GOMP_SIMT_ORDERED_PRED and others the answer was: elide the call.
(However, GOMP_SIMT_ORDERED_PRED doesn't seem to have ECF_* flags
that would normally allow it to be dropped at the gimple level.)
So these instructions seem to be special enough that they need
their own code after all. This patch reverts the second patch
and most of the first. The only part retained from the first
is splitting expand_fn_using_insn out of expand_direct_optab_fn,
since I think expand_fn_using_insn could still be useful in future.
gcc/
PR middle-end/105975
Revert everything apart from the expand_fn_using_insn and
expand_direct_optab_fn changes from:
* internal-fn.def (DEF_INTERNAL_INSN_FN): New macro.
(GOMP_SIMT_ENTER_ALLOC, GOMP_SIMT_EXIT, GOMP_SIMT_LANE)
(GOMP_SIMT_LAST_LANE, GOMP_SIMT_ORDERED_PRED, GOMP_SIMT_VOTE_ANY)
(GOMP_SIMT_XCHG_BFLY, GOMP_SIMT_XCHG_IDX): Use it.
* internal-fn.h (direct_internal_fn_info::directly_mapped): New
member variable.
(direct_internal_fn_info::vectorizable): Reduce to 1 bit.
(direct_internal_fn_p): Also return true for internal functions
that map directly to instructions defined target-insns.def.
(direct_internal_fn): Adjust comment accordingly.
* internal-fn.cc (direct_insn, optab1, optab2, vectorizable_optab1)
(vectorizable_optab2): New local macros.
(not_direct): Initialize directly_mapped.
(mask_load_direct, load_lanes_direct, mask_load_lanes_direct)
(gather_load_direct, len_load_direct, mask_store_direct)
(store_lanes_direct, mask_store_lanes_direct, vec_cond_mask_direct)
(vec_cond_direct, scatter_store_direct, len_store_direct)
(vec_set_direct, unary_direct, binary_direct, ternary_direct)
(cond_unary_direct, cond_binary_direct, cond_ternary_direct)
(while_direct, fold_extract_direct, fold_left_direct)
(mask_fold_left_direct, check_ptrs_direct): Use the macros above.
(expand_GOMP_SIMT_ENTER_ALLOC, expand_GOMP_SIMT_EXIT): Delete
(expand_GOMP_SIMT_LANE, expand_GOMP_SIMT_LAST_LANE): Likewise;
(expand_GOMP_SIMT_ORDERED_PRED, expand_GOMP_SIMT_VOTE_ANY):
Likewise.
(expand_GOMP_SIMT_XCHG_BFLY, expand_GOMP_SIMT_XCHG_IDX): Likewise.
(direct_internal_fn_types): Handle functions that map to
instructions
defined in target-insns.def.
(direct_internal_fn_types): Likewise.
(direct_internal_fn_supported_p): Likewise.
(internal_fn_expanders): Likewise.
(expand_fn_using_insn): New function,
split out and adapted from...
(expand_direct_optab_fn): ...here.
(expand_GOMP_SIMT_ENTER_ALLOC): Use it.
(expand_GOMP_SIMT_EXIT): Likewise.
(expand_GOMP_SIMT_LANE): Likewise.
(expand_GOMP_SIMT_LAST_LANE): Likewise.
(expand_GOMP_SIMT_ORDERED_PRED): Likewise.
(expand_GOMP_SIMT_VOTE_ANY): Likewise.
(expand_GOMP_SIMT_XCHG_BFLY): Likewise.
(expand_GOMP_SIMT_XCHG_IDX): Likewise.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/105975] OpenMP/nvptx offloading: 'internal compiler error: in maybe_legitimize_operand, at optabs.cc:7785'
2022-06-14 14:40 [Bug target/105975] New: OpenMP/nvptx offloading: 'internal compiler error: in maybe_legitimize_operand, at optabs.cc:7785' tschwinge at gcc dot gnu.org
` (4 preceding siblings ...)
2022-06-15 16:40 ` cvs-commit at gcc dot gnu.org
@ 2022-06-15 16:42 ` rsandifo at gcc dot gnu.org
2022-06-15 21:04 ` tschwinge at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: rsandifo at gcc dot gnu.org @ 2022-06-15 16:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105975
rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #6 from rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> ---
Should be fixed now.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/105975] OpenMP/nvptx offloading: 'internal compiler error: in maybe_legitimize_operand, at optabs.cc:7785'
2022-06-14 14:40 [Bug target/105975] New: OpenMP/nvptx offloading: 'internal compiler error: in maybe_legitimize_operand, at optabs.cc:7785' tschwinge at gcc dot gnu.org
` (5 preceding siblings ...)
2022-06-15 16:42 ` rsandifo at gcc dot gnu.org
@ 2022-06-15 21:04 ` tschwinge at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: tschwinge at gcc dot gnu.org @ 2022-06-15 21:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105975
--- Comment #7 from Thomas Schwinge <tschwinge at gcc dot gnu.org> ---
(In reply to rsandifo@gcc.gnu.org from comment #4)
> Thanks for the reproducer.
Glad that this approach did work.
(In reply to rsandifo@gcc.gnu.org from comment #6)
> Should be fixed now.
ACK, thanks. And sorry that you had to revert most of your changes! But I'm
not familiar enough with these OpenMP/nvptx 'GOMP_SIMT_[...]' codes to easily
come up with an idea about how to make this work in your refactored code.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-06-15 21:04 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-14 14:40 [Bug target/105975] New: OpenMP/nvptx offloading: 'internal compiler error: in maybe_legitimize_operand, at optabs.cc:7785' tschwinge at gcc dot gnu.org
2022-06-14 20:08 ` [Bug target/105975] " rsandifo at gcc dot gnu.org
2022-06-15 8:49 ` tschwinge at gcc dot gnu.org
2022-06-15 8:51 ` tschwinge at gcc dot gnu.org
2022-06-15 11:01 ` rsandifo at gcc dot gnu.org
2022-06-15 16:40 ` cvs-commit at gcc dot gnu.org
2022-06-15 16:42 ` rsandifo at gcc dot gnu.org
2022-06-15 21:04 ` tschwinge at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).