public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/113415] New: ICE: RTL check: expected elt 3 type 'e' or 'u', have '0' (rtx code_label) in PATTERN, at rtl.h:1511 with -mstringop-strategy=byte_loop and invalid __asm__ on _BitInt()
@ 2024-01-16  5:46 zsojka at seznam dot cz
  2024-01-16  6:00 ` [Bug middle-end/113415] " pinskia at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: zsojka at seznam dot cz @ 2024-01-16  5:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113415

            Bug ID: 113415
           Summary: ICE: RTL check: expected elt 3 type 'e' or 'u', have
                    '0' (rtx code_label) in PATTERN, at rtl.h:1511 with
                    -mstringop-strategy=byte_loop and invalid __asm__ on
                    _BitInt()
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: ice-on-invalid-code
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zsojka at seznam dot cz
  Target Milestone: ---
              Host: x86_64-pc-linux-gnu
            Target: x86_64-pc-linux-gnu

Created attachment 57097
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57097&action=edit
reduced testcase

This probably needs RTL checking enabled. The asm constraints are invalid; ICEs
before the diagnostics.

Compiler output:
$ x86_64-pc-linux-gnu-gcc -mstringop-strategy=byte_loop testcase.c
during RTL pass: expand
testcase.c: In function 'foo':
testcase.c:6:3: internal compiler error: RTL check: expected elt 3 type 'e' or
'u', have '0' (rtx code_label) in PATTERN, at rtl.h:1511
    6 |   __asm__ goto("" : "=r"(x) : : : lab);
      |   ^~~~~~~
0x800c3a rtl_check_failed_type2(rtx_def const*, int, int, int, char const*,
int, char const*)
        /repo/gcc-trunk/gcc/rtl.cc:761
0x724644 PATTERN(rtx_def*)
        /repo/gcc-trunk/gcc/rtl.h:1511
0x726bf6 PATTERN(rtx_def*)
        /repo/gcc-trunk/gcc/rtl.h:1479
0x726bf6 expand_asm_stmt
        /repo/gcc-trunk/gcc/cfgexpand.cc:3655
0xf88909 expand_gimple_stmt_1
        /repo/gcc-trunk/gcc/cfgexpand.cc:3897
0xf88909 expand_gimple_stmt
        /repo/gcc-trunk/gcc/cfgexpand.cc:4064
0xf8a007 expand_gimple_basic_block
        /repo/gcc-trunk/gcc/cfgexpand.cc:6120
0xf8c66e execute
        /repo/gcc-trunk/gcc/cfgexpand.cc:6855
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.

$ x86_64-pc-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=/repo/gcc-trunk/binary-latest-amd64/bin/x86_64-pc-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/repo/gcc-trunk/binary-trunk-r14-7258-20240115151353-g731444b3c39-checking-yes-rtl-df-extra-amd64/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /repo/gcc-trunk//configure --enable-languages=c,c++
--enable-valgrind-annotations --disable-nls --enable-checking=yes,rtl,df,extra
--with-cloog --with-ppl --with-isl --build=x86_64-pc-linux-gnu
--host=x86_64-pc-linux-gnu --target=x86_64-pc-linux-gnu
--with-ld=/usr/bin/x86_64-pc-linux-gnu-ld
--with-as=/usr/bin/x86_64-pc-linux-gnu-as --disable-libstdcxx-pch
--prefix=/repo/gcc-trunk//binary-trunk-r14-7258-20240115151353-g731444b3c39-checking-yes-rtl-df-extra-amd64
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.0.1 20240115 (experimental) (GCC)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug middle-end/113415] ICE: RTL check: expected elt 3 type 'e' or 'u', have '0' (rtx code_label) in PATTERN, at rtl.h:1511 with -mstringop-strategy=byte_loop and invalid __asm__ on _BitInt()
  2024-01-16  5:46 [Bug rtl-optimization/113415] New: ICE: RTL check: expected elt 3 type 'e' or 'u', have '0' (rtx code_label) in PATTERN, at rtl.h:1511 with -mstringop-strategy=byte_loop and invalid __asm__ on _BitInt() zsojka at seznam dot cz
@ 2024-01-16  6:00 ` pinskia at gcc dot gnu.org
  2024-01-16  6:07 ` [Bug middle-end/113415] ICE: RTL check: -mstringop-strategy=byte_loop vs inline-asm goto with block copies pinskia at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-01-16  6:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113415

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This might fail the same way:
```
void
foo(void)
{
  unsigned long bitint0[64];
lab:
  __asm__ goto("" : "=r"(bitint0) : : : lab);
}
```

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug middle-end/113415] ICE: RTL check:  -mstringop-strategy=byte_loop vs inline-asm  goto with block copies
  2024-01-16  5:46 [Bug rtl-optimization/113415] New: ICE: RTL check: expected elt 3 type 'e' or 'u', have '0' (rtx code_label) in PATTERN, at rtl.h:1511 with -mstringop-strategy=byte_loop and invalid __asm__ on _BitInt() zsojka at seznam dot cz
  2024-01-16  6:00 ` [Bug middle-end/113415] " pinskia at gcc dot gnu.org
@ 2024-01-16  6:07 ` pinskia at gcc dot gnu.org
  2024-01-18 23:03 ` pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-01-16  6:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113415

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|ICE: RTL check: expected    |ICE: RTL check:
                   |elt 3 type 'e' or 'u', have |-mstringop-strategy=byte_lo
                   |'0' (rtx code_label) in     |op vs inline-asm  goto with
                   |PATTERN, at rtl.h:1511 with |block copies
                   |-mstringop-strategy=byte_lo |
                   |op and invalid __asm__ on   |
                   |_BitInt()                   |
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2024-01-16

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This code will not work with anything more fancy than insns, it does not
support code_labels.

```
              for (rtx_insn *curr = after_rtl_seq;
                   curr != NULL_RTX;
                   curr = NEXT_INSN (curr))
                emit_insn (copy_insn (PATTERN (curr)));
              rtx_insn *copy = get_insns ();
              end_sequence ();

```

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug middle-end/113415] ICE: RTL check:  -mstringop-strategy=byte_loop vs inline-asm  goto with block copies
  2024-01-16  5:46 [Bug rtl-optimization/113415] New: ICE: RTL check: expected elt 3 type 'e' or 'u', have '0' (rtx code_label) in PATTERN, at rtl.h:1511 with -mstringop-strategy=byte_loop and invalid __asm__ on _BitInt() zsojka at seznam dot cz
  2024-01-16  6:00 ` [Bug middle-end/113415] " pinskia at gcc dot gnu.org
  2024-01-16  6:07 ` [Bug middle-end/113415] ICE: RTL check: -mstringop-strategy=byte_loop vs inline-asm goto with block copies pinskia at gcc dot gnu.org
@ 2024-01-18 23:03 ` pinskia at gcc dot gnu.org
  2024-01-18 23:05 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-01-18 23:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113415

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |inline-asm
      Known to fail|                            |11.1.0, 13.2.0

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #1)
> This might fail the same way:

It fails in the same way. And it has failed since asm goto was added too.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug middle-end/113415] ICE: RTL check:  -mstringop-strategy=byte_loop vs inline-asm  goto with block copies
  2024-01-16  5:46 [Bug rtl-optimization/113415] New: ICE: RTL check: expected elt 3 type 'e' or 'u', have '0' (rtx code_label) in PATTERN, at rtl.h:1511 with -mstringop-strategy=byte_loop and invalid __asm__ on _BitInt() zsojka at seznam dot cz
                   ` (2 preceding siblings ...)
  2024-01-18 23:03 ` pinskia at gcc dot gnu.org
@ 2024-01-18 23:05 ` pinskia at gcc dot gnu.org
  2024-02-07 21:33 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-01-18 23:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113415

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note without RTL checking we get:
```
<source>:7:3: error: impossible constraint in 'asm'
    7 |   __asm__ goto("" : "=r"(bitint0) : : : lab);
      |   ^~~~~~~
<source>:8:1: error: wrong number of branch edges after unconditional jump in
bb 5
    8 | }
      | ^
<source>:8:1: error: wrong number of branch edges after unconditional jump in
bb 3
during RTL pass: cse1
dump file: /app/output.cpp.272r.cse1
<source>:8:1: internal compiler error: verify_flow_info failed
0x2332cfc internal_error(char const*, ...)
        ???:0
0xb27bd3 verify_flow_info()
        ???:0
0x2003c7c cleanup_cfg(int)
        ???:0
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.
```

With release checking we get an ICE after the first error; the `confused by
earlier errors, bailing out`.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug middle-end/113415] ICE: RTL check:  -mstringop-strategy=byte_loop vs inline-asm  goto with block copies
  2024-01-16  5:46 [Bug rtl-optimization/113415] New: ICE: RTL check: expected elt 3 type 'e' or 'u', have '0' (rtx code_label) in PATTERN, at rtl.h:1511 with -mstringop-strategy=byte_loop and invalid __asm__ on _BitInt() zsojka at seznam dot cz
                   ` (3 preceding siblings ...)
  2024-01-18 23:05 ` pinskia at gcc dot gnu.org
@ 2024-02-07 21:33 ` pinskia at gcc dot gnu.org
  2024-02-08 17:54 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-07 21:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113415

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 113819 has been marked as a duplicate of this bug. ***

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug middle-end/113415] ICE: RTL check:  -mstringop-strategy=byte_loop vs inline-asm  goto with block copies
  2024-01-16  5:46 [Bug rtl-optimization/113415] New: ICE: RTL check: expected elt 3 type 'e' or 'u', have '0' (rtx code_label) in PATTERN, at rtl.h:1511 with -mstringop-strategy=byte_loop and invalid __asm__ on _BitInt() zsojka at seznam dot cz
                   ` (4 preceding siblings ...)
  2024-02-07 21:33 ` pinskia at gcc dot gnu.org
@ 2024-02-08 17:54 ` jakub at gcc dot gnu.org
  2024-02-09 10:09 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-02-08 17:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113415

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 57364
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57364&action=edit
gcc14-pr113415.patch

If all we care here is not to ICE on it, then this patch should suffice.
But, if there is some asm goto where such loops could be emitted and needed on
all the asm goto edges, then more work will be needed,
duplicate_insn_chain doesn't duplicate CODE_LABELs and remap references to them
in the copied sequences.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug middle-end/113415] ICE: RTL check:  -mstringop-strategy=byte_loop vs inline-asm  goto with block copies
  2024-01-16  5:46 [Bug rtl-optimization/113415] New: ICE: RTL check: expected elt 3 type 'e' or 'u', have '0' (rtx code_label) in PATTERN, at rtl.h:1511 with -mstringop-strategy=byte_loop and invalid __asm__ on _BitInt() zsojka at seznam dot cz
                   ` (5 preceding siblings ...)
  2024-02-08 17:54 ` jakub at gcc dot gnu.org
@ 2024-02-09 10:09 ` cvs-commit at gcc dot gnu.org
  2024-02-09 10:13 ` jakub at gcc dot gnu.org
  2024-02-14 17:25 ` pinskia at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-02-09 10:09 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113415

--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:0ad1884089c0fad4dfc72516bc68ec508cba1832

commit r14-8896-g0ad1884089c0fad4dfc72516bc68ec508cba1832
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Feb 9 11:08:33 2024 +0100

    expand: Fix asm goto expansion [PR113415]

    The asm goto expansion ICEs on the following testcase (which normally
    is rejected later), because expand_asm_stmt emits the code to copy
    the large var out of the out operand to its memory location into
    after_rtl_seq ... after_rtl_end sequence and because it is asm goto,
    it duplicates the sequence on each successor edge of the asm goto.
    The problem is that with -mstringop-strategy=byte_loop that sequence
    contains loops, so CODE_LABELs, JUMP_INSNs, with other strategies
    could contain CALL_INSNs etc.
    But the copying is done using a loop doing
    emit_insn (copy_insn (PATTERN (curr)));
    which does the right thing solely for INSNs, it will do the wrong thing
    for JUMP_INSNs, CALL_INSNs, CODE_LABELs (with RTL checking even ICE on
    them), BARRIERs and the like.

    The following patch partially fixes it (with the hope that such stuff only
    occurs in asms that really can't be accepted; if one uses say "=rm" or
    "=g" constraint then the operand uses the memory directly and nothing is
    copied) by using the
    duplicate_insn_chain function which is used e.g. in RTL loop unrolling and
    which can handle JUMP_INSNs, CALL_INSNs, BARRIERs etc.
    As it is meant to operate on sequences inside of basic blocks, it doesn't
    handle CODE_LABELs (well, it skips them), so if we need a solution that
    will be correct at runtime here for those cases, we'd need to do further
    work (e.g. still use duplicate_insn_chain, but if we notice any
CODE_LABELs,
    walk the sequence again, add copies of the CODE_LABELs and then remap
    references to the old CODE_LABELs in the copied sequence to the new ones).
    Because as is now, if the code in one of the sequence copies (where the
    CODE_LABELs have been left out) decides to jump to such a CODE_LABEL, it
    will jump to the CODE_LABEL which has been in the original sequence (which
    the code emits on the last edge, after all, duplicating the sequence
    EDGE_COUNT times and throwing away the original was wasteful, compared to
    doing that just EDGE_COUNT - 1 times and using the original.

    2024-02-09  Jakub Jelinek  <jakub@redhat.com>

            PR middle-end/113415
            * cfgexpand.cc (expand_asm_stmt): For asm goto, use
            duplicate_insn_chain to duplicate after_rtl_seq sequence instead
            of hand written loop with emit_insn of copy_insn and emit original
            after_rtl_seq on the last edge.

            * gcc.target/i386/pr113415.c: New test.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug middle-end/113415] ICE: RTL check:  -mstringop-strategy=byte_loop vs inline-asm  goto with block copies
  2024-01-16  5:46 [Bug rtl-optimization/113415] New: ICE: RTL check: expected elt 3 type 'e' or 'u', have '0' (rtx code_label) in PATTERN, at rtl.h:1511 with -mstringop-strategy=byte_loop and invalid __asm__ on _BitInt() zsojka at seznam dot cz
                   ` (6 preceding siblings ...)
  2024-02-09 10:09 ` cvs-commit at gcc dot gnu.org
@ 2024-02-09 10:13 ` jakub at gcc dot gnu.org
  2024-02-14 17:25 ` pinskia at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-02-09 10:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113415

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug middle-end/113415] ICE: RTL check:  -mstringop-strategy=byte_loop vs inline-asm  goto with block copies
  2024-01-16  5:46 [Bug rtl-optimization/113415] New: ICE: RTL check: expected elt 3 type 'e' or 'u', have '0' (rtx code_label) in PATTERN, at rtl.h:1511 with -mstringop-strategy=byte_loop and invalid __asm__ on _BitInt() zsojka at seznam dot cz
                   ` (7 preceding siblings ...)
  2024-02-09 10:13 ` jakub at gcc dot gnu.org
@ 2024-02-14 17:25 ` pinskia at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-14 17:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113415

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |14.0

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-02-14 17:25 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-16  5:46 [Bug rtl-optimization/113415] New: ICE: RTL check: expected elt 3 type 'e' or 'u', have '0' (rtx code_label) in PATTERN, at rtl.h:1511 with -mstringop-strategy=byte_loop and invalid __asm__ on _BitInt() zsojka at seznam dot cz
2024-01-16  6:00 ` [Bug middle-end/113415] " pinskia at gcc dot gnu.org
2024-01-16  6:07 ` [Bug middle-end/113415] ICE: RTL check: -mstringop-strategy=byte_loop vs inline-asm goto with block copies pinskia at gcc dot gnu.org
2024-01-18 23:03 ` pinskia at gcc dot gnu.org
2024-01-18 23:05 ` pinskia at gcc dot gnu.org
2024-02-07 21:33 ` pinskia at gcc dot gnu.org
2024-02-08 17:54 ` jakub at gcc dot gnu.org
2024-02-09 10:09 ` cvs-commit at gcc dot gnu.org
2024-02-09 10:13 ` jakub at gcc dot gnu.org
2024-02-14 17:25 ` pinskia 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).