public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/105853] New: ice in pieces_addr constructor
@ 2022-06-05  7:12 dcb314 at hotmail dot com
  2022-06-05  7:16 ` [Bug middle-end/105853] [13 regression] " pinskia at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: dcb314 at hotmail dot com @ 2022-06-05  7:12 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105853
           Summary: ice in pieces_addr constructor
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dcb314 at hotmail dot com
  Target Milestone: ---

Created attachment 53086
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53086&action=edit
C source code

The attached C code does this:

$ ../results/bin/gcc -c -w -march=bdver2 bug818.c
during RTL pass: expand
lib/packets.c: In function ‘compose_nd_ns’:
lib/packets.c:1701:5: internal compiler error: Segmentation fault
0xdad1c9 crash_signal(int)
        /home/dcb/gcc/working/gcc/../../trunk.git/gcc/toplev.cc:322
0x955a4d pieces_addr::pieces_addr(rtx_def*, bool, rtx_def* (*)(void*, void*,
long, fixed_size_mode), void*)
        /home/dcb/gcc/working/gcc/../../trunk.git/gcc/expr.cc:996
0x955a4d op_by_pieces_d::op_by_pieces_d(unsigned int, rtx_def*, bool, rtx_def*,
bool, rtx_def* (*)(void*, void*, l
ong, fixed_size_mode), void*, unsigned long, unsigned int, bool, bool)
        /home/dcb/gcc/working/gcc/../../trunk.git/gcc/expr.cc:1174

The code seems to break sometime between git hash 919822adc923b00e
and aec868578d851576.

I will have my usual go at reducing the code.

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

* [Bug middle-end/105853] [13 regression] ice in pieces_addr constructor
  2022-06-05  7:12 [Bug c/105853] New: ice in pieces_addr constructor dcb314 at hotmail dot com
@ 2022-06-05  7:16 ` pinskia at gcc dot gnu.org
  2022-06-05  7:34 ` dcb314 at hotmail dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-06-05  7:16 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |13.0
            Version|12.0                        |13.0
            Summary|ice in pieces_addr          |[13 regression] ice in
                   |constructor                 |pieces_addr constructor
           Keywords|                            |ice-on-valid-code
          Component|c                           |middle-end

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

* [Bug middle-end/105853] [13 regression] ice in pieces_addr constructor
  2022-06-05  7:12 [Bug c/105853] New: ice in pieces_addr constructor dcb314 at hotmail dot com
  2022-06-05  7:16 ` [Bug middle-end/105853] [13 regression] " pinskia at gcc dot gnu.org
@ 2022-06-05  7:34 ` dcb314 at hotmail dot com
  2022-06-05 21:40 ` roger at nextmovesoftware dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: dcb314 at hotmail dot com @ 2022-06-05  7:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from David Binderman <dcb314 at hotmail dot com> ---
Reduced C code seems to be:

struct {
  struct {
    short e16[3];
  }
} const eth_addr_zero = {{}};
void compose_nd_na_ipv6_src() { packet_set_nd(eth_addr_zero); }

Note no -march= setting is required.

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

* [Bug middle-end/105853] [13 regression] ice in pieces_addr constructor
  2022-06-05  7:12 [Bug c/105853] New: ice in pieces_addr constructor dcb314 at hotmail dot com
  2022-06-05  7:16 ` [Bug middle-end/105853] [13 regression] " pinskia at gcc dot gnu.org
  2022-06-05  7:34 ` dcb314 at hotmail dot com
@ 2022-06-05 21:40 ` roger at nextmovesoftware dot com
  2022-06-06 13:51 ` roger at nextmovesoftware dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: roger at nextmovesoftware dot com @ 2022-06-05 21:40 UTC (permalink / raw)
  To: gcc-bugs

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

Roger Sayle <roger at nextmovesoftware dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-06-05
           Priority|P3                          |P1
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1
                 CC|                            |roger at nextmovesoftware dot com
           Assignee|unassigned at gcc dot gnu.org      |roger at nextmovesoftware dot com

--- Comment #2 from Roger Sayle <roger at nextmovesoftware dot com> ---
Doh!  Mine.  Sorry for the breakage.  My patch/solution for PR 105856 also
resolves this PR.  Calling expand_expr with a DECL_INITIAL CONSTRUCTOR from
load_register_parameters can trigger unintended pathways, instead we/I need to
call the lower level store_constructor directly.

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

* [Bug middle-end/105853] [13 regression] ice in pieces_addr constructor
  2022-06-05  7:12 [Bug c/105853] New: ice in pieces_addr constructor dcb314 at hotmail dot com
                   ` (2 preceding siblings ...)
  2022-06-05 21:40 ` roger at nextmovesoftware dot com
@ 2022-06-06 13:51 ` roger at nextmovesoftware dot com
  2022-06-07  9:13 ` cvs-commit at gcc dot gnu.org
  2022-06-09 11:13 ` roger at nextmovesoftware dot com
  5 siblings, 0 replies; 7+ messages in thread
From: roger at nextmovesoftware dot com @ 2022-06-06 13:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Roger Sayle <roger at nextmovesoftware dot com> ---
Patch proposed:
https://gcc.gnu.org/pipermail/gcc-patches/2022-June/596242.html

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

* [Bug middle-end/105853] [13 regression] ice in pieces_addr constructor
  2022-06-05  7:12 [Bug c/105853] New: ice in pieces_addr constructor dcb314 at hotmail dot com
                   ` (3 preceding siblings ...)
  2022-06-06 13:51 ` roger at nextmovesoftware dot com
@ 2022-06-07  9:13 ` cvs-commit at gcc dot gnu.org
  2022-06-09 11:13 ` roger at nextmovesoftware dot com
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-06-07  9:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Roger Sayle <sayle@gcc.gnu.org>:

https://gcc.gnu.org/g:c00e1e3aa5ae62a991d105d309061d12f6a8764f

commit r13-1004-gc00e1e3aa5ae62a991d105d309061d12f6a8764f
Author: Roger Sayle <roger@nextmovesoftware.com>
Date:   Tue Jun 7 10:09:49 2022 +0100

    PR middle-end/105853: Call store_constructor directly from calls.cc.

    This patch fixes both ICE regressions PR middle-end/105853 and
    PR target/105856 caused by my recent patch to expand small const structs
    as immediate constants.  That patch updated code generation in three
    places: two in expr.cc that call store_constructor directly, and the
    third in calls.cc's load_register_parameters that expands its CONSTRUCTOR
    via expand_expr, as store_constructor is local/static to expr.cc, and
    the "public" API, should usually simply forward the constructor to the
    appropriate store_constructor function.

    Alas, despite the clean regression testing on multiple targets, the above
    ICEs show that expand_expr isn't a suitable proxy for store_constructor,
    and things that (I'd assumed) shouldn't affect how/whether a struct is
    placed in a register [such as whether the struct is considered packed/
    aligned or not] actually interfere with the optimization that is being
    attempted.

    The (proposed) solution is to export store_constructor (and it's helper
    function int_expr_size) from expr.cc, by removing their static qualifier
    and prototyping both functions in expr.h, so they can be called directly
    from load_register_parameters in calls.cc.  This cures both ICEs, but
    almost as importantly improves code generation over GCC 12.

    For PR 105853, GCC 12 generates:

    compose_nd_na_ipv6_src:
            movzx eax, WORD PTR eth_addr_zero[rip+2]
            movzx edx, WORD PTR eth_addr_zero[rip]
            movzx edi, WORD PTR eth_addr_zero[rip+4]
            sal rax, 16
            or rax, rdx
            sal rdi, 32
            or rdi, rax
            xor eax, eax
            jmp packet_set_nd
    eth_addr_zero:  .zero 6

    where now (with this fix) GCC 13 generates:
    compose_nd_na_ipv6_src:
            xorl    %edi, %edi
            xorl    %eax, %eax
            jmp     packet_set_nd

    Likewise, for PR 105856 on ARM, we'd previously generate:
    g_329_3:
            movw r3, #:lower16:.LANCHOR0
            movt r3, #:upper16:.LANCHOR0
            ldr r0, [r3]
            b func_19

    but with this optimization we now generate:
    g_329_3:
            mov     r0, #6
            b       func_19

    2022-06-07  Roger Sayle  <roger@nextmovesoftware.com>

    gcc/ChangeLog
            PR middle-end/105853
            PR target/105856
            * calls.cc (load_register_parameters): Call store_constructor
            and int_expr_size directly instead of expanding via expand_expr.
            * expr.cc (static void store_constructor): Don't prototype here.
            (static HOST_WIDE_INT int_expr_size): Likewise.
            (store_constructor): No longer static.
            (int_expr_size): Likewise, no longer static.
            * expr.h (store_constructor): Prototype here.
            (int_expr_size): Prototype here.

    gcc/testsuite/ChangeLog
            PR middle-end/105853
            PR target/105856
            * gcc.dg/pr105853.c: New test case.
            * gcc.dg/pr105856.c: New test case.

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

* [Bug middle-end/105853] [13 regression] ice in pieces_addr constructor
  2022-06-05  7:12 [Bug c/105853] New: ice in pieces_addr constructor dcb314 at hotmail dot com
                   ` (4 preceding siblings ...)
  2022-06-07  9:13 ` cvs-commit at gcc dot gnu.org
@ 2022-06-09 11:13 ` roger at nextmovesoftware dot com
  5 siblings, 0 replies; 7+ messages in thread
From: roger at nextmovesoftware dot com @ 2022-06-09 11:13 UTC (permalink / raw)
  To: gcc-bugs

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

Roger Sayle <roger at nextmovesoftware dot com> changed:

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

--- Comment #5 from Roger Sayle <roger at nextmovesoftware dot com> ---
This should now be fixed on mainline.  Sorry for the breakage.

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

end of thread, other threads:[~2022-06-09 11:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-05  7:12 [Bug c/105853] New: ice in pieces_addr constructor dcb314 at hotmail dot com
2022-06-05  7:16 ` [Bug middle-end/105853] [13 regression] " pinskia at gcc dot gnu.org
2022-06-05  7:34 ` dcb314 at hotmail dot com
2022-06-05 21:40 ` roger at nextmovesoftware dot com
2022-06-06 13:51 ` roger at nextmovesoftware dot com
2022-06-07  9:13 ` cvs-commit at gcc dot gnu.org
2022-06-09 11:13 ` roger at nextmovesoftware dot com

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).