public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/105165] New: [11/12 Regression] ICE in gimple_redirect_edge_and_branch, at tree-cfg.cc:6136
@ 2022-04-05 16:18 gscfq@t-online.de
  2022-04-05 16:30 ` [Bug c/105165] " jakub at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: gscfq@t-online.de @ 2022-04-05 16:18 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105165
           Summary: [11/12 Regression] ICE in
                    gimple_redirect_edge_and_branch, at tree-cfg.cc:6136
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gscfq@t-online.de
  Target Milestone: ---

Started between 20201108 and 20201115, at -O1+ :
(derived from pr100329.c)


$ cat z1.c
unsigned int _Complex a0;
unsigned int _Complex
foo (unsigned int _Complex a1, unsigned int _Complex a2)
{
  unsigned int _Complex x;
  asm goto ("" : "=r" (x) : : : lab);
  a0 = x;
 lab:
  return x + a1 + a2 + 1;
}


$ gcc-12-20220403 -c z1.c -O2
during GIMPLE pass: pre
z1.c: In function 'foo':
z1.c:3:1: internal compiler error: in gimple_redirect_edge_and_branch, at
tree-cfg.cc:6136
    3 | foo (unsigned int _Complex a1, unsigned int _Complex a2)
      | ^~~
0xc611c5 gimple_redirect_edge_and_branch
        ../../gcc/tree-cfg.cc:6136
0x7d3139 redirect_edge_and_branch(edge_def*, basic_block_def*)
        ../../gcc/cfghooks.cc:388
0xc593b8 gimple_split_edge
        ../../gcc/tree-cfg.cc:2983
0x7d37c5 split_edge(edge_def*)
        ../../gcc/cfghooks.cc:668
0xc61f67 split_critical_edges(bool)
        ../../gcc/tree-cfg.cc:9172
0xda6ab1 split_edges_for_insertion()
        ../../gcc/tree-cfg.h:130
0xda6ab1 execute
        ../../gcc/tree-ssa-pre.cc:4402

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

* [Bug c/105165] [11/12 Regression] ICE in gimple_redirect_edge_and_branch, at tree-cfg.cc:6136
  2022-04-05 16:18 [Bug c/105165] New: [11/12 Regression] ICE in gimple_redirect_edge_and_branch, at tree-cfg.cc:6136 gscfq@t-online.de
@ 2022-04-05 16:30 ` jakub at gcc dot gnu.org
  2022-04-06  7:53 ` [Bug tree-optimization/105165] " rguenth at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-04-05 16:30 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2022-04-05

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
This started with r11-5002-ge3b3b59683c1e7d31a9d313dd97394abebf644be so not
really sure if we can call it a regression.
It is a regression in that something that didn't ICE before now ICEs, but it
was invalid before and now is valid.

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

* [Bug tree-optimization/105165] ICE in gimple_redirect_edge_and_branch, at tree-cfg.cc:6136
  2022-04-05 16:18 [Bug c/105165] New: [11/12 Regression] ICE in gimple_redirect_edge_and_branch, at tree-cfg.cc:6136 gscfq@t-online.de
  2022-04-05 16:30 ` [Bug c/105165] " jakub at gcc dot gnu.org
@ 2022-04-06  7:53 ` rguenth at gcc dot gnu.org
  2022-04-06 10:43 ` rguenth at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-04-06  7:53 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org
          Component|c                           |tree-optimization
             Status|NEW                         |ASSIGNED
            Summary|[11/12 Regression] ICE in   |ICE in
                   |gimple_redirect_edge_and_br |gimple_redirect_edge_and_br
                   |anch, at tree-cfg.cc:6136   |anch, at tree-cfg.cc:6136

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
I will have a look.

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

* [Bug tree-optimization/105165] ICE in gimple_redirect_edge_and_branch, at tree-cfg.cc:6136
  2022-04-05 16:18 [Bug c/105165] New: [11/12 Regression] ICE in gimple_redirect_edge_and_branch, at tree-cfg.cc:6136 gscfq@t-online.de
  2022-04-05 16:30 ` [Bug c/105165] " jakub at gcc dot gnu.org
  2022-04-06  7:53 ` [Bug tree-optimization/105165] " rguenth at gcc dot gnu.org
@ 2022-04-06 10:43 ` rguenth at gcc dot gnu.org
  2022-04-06 11:10 ` jakub at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-04-06 10:43 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |NEW
           Assignee|rguenth at gcc dot gnu.org         |unassigned at gcc dot gnu.org
                 CC|                            |rguenth at gcc dot gnu.org,
                   |                            |vmakarov at gcc dot gnu.org

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
It's complex lowering not being able to deal with the _Complex definition in
the
asm goto.  Why do we allow asm gotos to have outputs?

__complex__ unsigned int foo (__complex__ unsigned int a1, __complex__ unsigned
int a2)
{
  __complex__ unsigned int x;
  __complex__ unsigned int _1;
  __complex__ unsigned int _2;
  __complex__ unsigned int _9;

  <bb 2> [local count: 1073741824]:
  __asm__ goto("" : "=r" x_4 :  :  : "lab" lab);

  <bb 3> [local count: 536870913]:
  a0 = x_4;

  <bb 4> [local count: 1073741824]:
lab:
  _1 = x_4 + a1_7(D);
  _2 = _1 + a2_8(D);
  _9 = _2 + __complex__ (1, 0);
  return _9;

complex lowering isn't prepared for this.  The only thing it could do is
emit a copy on each edge and adjust SSA form accordingly but in the end
that would be expensive.  That said, the "proper" lowering would possibly
rewrite the asm in-place to sth like

  asm goto ("" : "=rR" (x$real), "=rR" (x$imag) : : : lab);


Again - why are outputs allowed for asm goto?  Can we at least disallow
complex typed outputs?

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

* [Bug tree-optimization/105165] ICE in gimple_redirect_edge_and_branch, at tree-cfg.cc:6136
  2022-04-05 16:18 [Bug c/105165] New: [11/12 Regression] ICE in gimple_redirect_edge_and_branch, at tree-cfg.cc:6136 gscfq@t-online.de
                   ` (2 preceding siblings ...)
  2022-04-06 10:43 ` rguenth at gcc dot gnu.org
@ 2022-04-06 11:10 ` jakub at gcc dot gnu.org
  2022-04-06 11:22 ` rguenther at suse dot de
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-04-06 11:10 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Outputs from asm goto has been strongly demanded feature from mainly linux
kernel folks.
Allowing all but complex outputs from asm goto would be just weird.

I think if we can't punt on the cplx lowering for certain SSA_NAMEs (force them
to be extracted before all uses instead), we'd need to extract them on all the
edges from the asm goto (if they have a single predecessor, the asm goto, at
the start of those bbs, if they have multiple, split the edges and adjust
labels) but then we'd need to create PHIs somewhere.

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

* [Bug tree-optimization/105165] ICE in gimple_redirect_edge_and_branch, at tree-cfg.cc:6136
  2022-04-05 16:18 [Bug c/105165] New: [11/12 Regression] ICE in gimple_redirect_edge_and_branch, at tree-cfg.cc:6136 gscfq@t-online.de
                   ` (3 preceding siblings ...)
  2022-04-06 11:10 ` jakub at gcc dot gnu.org
@ 2022-04-06 11:22 ` rguenther at suse dot de
  2022-04-06 11:31 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenther at suse dot de @ 2022-04-06 11:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from rguenther at suse dot de <rguenther at suse dot de> ---
On Wed, 6 Apr 2022, jakub at gcc dot gnu.org wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105165
> 
> --- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
> Outputs from asm goto has been strongly demanded feature from mainly linux
> kernel folks.
> Allowing all but complex outputs from asm goto would be just weird.
> 
> I think if we can't punt on the cplx lowering for certain SSA_NAMEs (force them
> to be extracted before all uses instead), we'd need to extract them on all the
> edges from the asm goto (if they have a single predecessor, the asm goto, at
> the start of those bbs, if they have multiple, split the edges and adjust
> labels) but then we'd need to create PHIs somewhere.

The complex lowering machinery is currently neither set up to extract
before all uses nor to emit multiple copies on edges and update SSA
form accordingly for the ongoing rewrite.

I suppose the easiest thing to do would be to prepare the edge emission
upfront by emitting copies on all outgoing edges, updating SSA form
there (replace all uses with a bare decl, assign to the decl and then
rewrite that into SSA via update_ssa).  And then just assume duplicate
emission to each edge is "trivially" possible by consuming the copy
stmt (actually re-writing that).

But that feels like a hack for a feature going wrong :/  We should
have a way to have an asm output that's CONCAT (real, imag), that
would simplify things a lot here.

Anyway, nobody is going to run into this in practice.  Maybe
instead of ICEing we can just sorry from complex lowering ... eh.

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

* [Bug tree-optimization/105165] ICE in gimple_redirect_edge_and_branch, at tree-cfg.cc:6136
  2022-04-05 16:18 [Bug c/105165] New: [11/12 Regression] ICE in gimple_redirect_edge_and_branch, at tree-cfg.cc:6136 gscfq@t-online.de
                   ` (4 preceding siblings ...)
  2022-04-06 11:22 ` rguenther at suse dot de
@ 2022-04-06 11:31 ` jakub at gcc dot gnu.org
  2022-04-06 11:36 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-04-06 11:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to rguenther@suse.de from comment #5)
> Anyway, nobody is going to run into this in practice.  Maybe
> instead of ICEing we can just sorry from complex lowering ... eh.

For GCC 11/12 that sounds like a good idea, sure.

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

* [Bug tree-optimization/105165] ICE in gimple_redirect_edge_and_branch, at tree-cfg.cc:6136
  2022-04-05 16:18 [Bug c/105165] New: [11/12 Regression] ICE in gimple_redirect_edge_and_branch, at tree-cfg.cc:6136 gscfq@t-online.de
                   ` (5 preceding siblings ...)
  2022-04-06 11:31 ` jakub at gcc dot gnu.org
@ 2022-04-06 11:36 ` rguenth at gcc dot gnu.org
  2022-04-07  6:17 ` [Bug tree-optimization/105165] Complex lowering does not handle asm goto with complex output; " cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-04-06 11:36 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
OK, let me do that.

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

* [Bug tree-optimization/105165] Complex lowering does not handle asm goto with complex output; ICE in gimple_redirect_edge_and_branch, at tree-cfg.cc:6136
  2022-04-05 16:18 [Bug c/105165] New: [11/12 Regression] ICE in gimple_redirect_edge_and_branch, at tree-cfg.cc:6136 gscfq@t-online.de
                   ` (6 preceding siblings ...)
  2022-04-06 11:36 ` rguenth at gcc dot gnu.org
@ 2022-04-07  6:17 ` cvs-commit at gcc dot gnu.org
  2022-04-07  7:00 ` cvs-commit at gcc dot gnu.org
  2022-04-07  7:01 ` rguenth at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-07  6:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:54ed6563d22694aa3e1935f89641a4f696a3a9f7

commit r12-8040-g54ed6563d22694aa3e1935f89641a4f696a3a9f7
Author: Richard Biener <rguenther@suse.de>
Date:   Wed Apr 6 13:46:56 2022 +0200

    middle-end/105165 - sorry instead of ICE for _Complex asm goto

    Complex lowering cannot currently deal with asm gotos with _Complex
    output operands.  Emit a sorry instead of ICEing, those should not
    appear in practice.

    2022-04-06  Richard Biener  <rguenther@suse.de>

            PR middle-end/105165
            * tree-complex.cc (expand_complex_asm): Sorry for asm goto
            _Complex outputs.

            * gcc.dg/pr105165.c: New testcase.

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

* [Bug tree-optimization/105165] Complex lowering does not handle asm goto with complex output; ICE in gimple_redirect_edge_and_branch, at tree-cfg.cc:6136
  2022-04-05 16:18 [Bug c/105165] New: [11/12 Regression] ICE in gimple_redirect_edge_and_branch, at tree-cfg.cc:6136 gscfq@t-online.de
                   ` (7 preceding siblings ...)
  2022-04-07  6:17 ` [Bug tree-optimization/105165] Complex lowering does not handle asm goto with complex output; " cvs-commit at gcc dot gnu.org
@ 2022-04-07  7:00 ` cvs-commit at gcc dot gnu.org
  2022-04-07  7:01 ` rguenth at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-07  7:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:

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

commit r11-9779-gd54cc1f43e53e52f52d1ae37f292b813e43d0b7b
Author: Richard Biener <rguenther@suse.de>
Date:   Wed Apr 6 13:46:56 2022 +0200

    middle-end/105165 - sorry instead of ICE for _Complex asm goto

    Complex lowering cannot currently deal with asm gotos with _Complex
    output operands.  Emit a sorry instead of ICEing, those should not
    appear in practice.

    2022-04-06  Richard Biener  <rguenther@suse.de>

            PR middle-end/105165
            * tree-complex.c (expand_complex_asm): Sorry for asm goto
            _Complex outputs.

            * gcc.dg/pr105165.c: New testcase.

    (cherry picked from commit 54ed6563d22694aa3e1935f89641a4f696a3a9f7)

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

* [Bug tree-optimization/105165] Complex lowering does not handle asm goto with complex output; ICE in gimple_redirect_edge_and_branch, at tree-cfg.cc:6136
  2022-04-05 16:18 [Bug c/105165] New: [11/12 Regression] ICE in gimple_redirect_edge_and_branch, at tree-cfg.cc:6136 gscfq@t-online.de
                   ` (8 preceding siblings ...)
  2022-04-07  7:00 ` cvs-commit at gcc dot gnu.org
@ 2022-04-07  7:01 ` rguenth at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-04-07  7:01 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|rguenth at gcc dot gnu.org         |unassigned at gcc dot gnu.org
             Status|ASSIGNED                    |NEW
           Keywords|ice-on-valid-code           |rejects-valid

--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed - it's now a sorry() and thus rejects-valid, for future enhancement if a
real use comes up.

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

end of thread, other threads:[~2022-04-07  7:01 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-05 16:18 [Bug c/105165] New: [11/12 Regression] ICE in gimple_redirect_edge_and_branch, at tree-cfg.cc:6136 gscfq@t-online.de
2022-04-05 16:30 ` [Bug c/105165] " jakub at gcc dot gnu.org
2022-04-06  7:53 ` [Bug tree-optimization/105165] " rguenth at gcc dot gnu.org
2022-04-06 10:43 ` rguenth at gcc dot gnu.org
2022-04-06 11:10 ` jakub at gcc dot gnu.org
2022-04-06 11:22 ` rguenther at suse dot de
2022-04-06 11:31 ` jakub at gcc dot gnu.org
2022-04-06 11:36 ` rguenth at gcc dot gnu.org
2022-04-07  6:17 ` [Bug tree-optimization/105165] Complex lowering does not handle asm goto with complex output; " cvs-commit at gcc dot gnu.org
2022-04-07  7:00 ` cvs-commit at gcc dot gnu.org
2022-04-07  7:01 ` rguenth 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).