public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/96931] New: [11 Regression] ICE in add_phi_arg, at tree-phinodes.c:359
@ 2020-09-04  6:50 asolokha at gmx dot com
  2020-09-04  7:49 ` [Bug tree-optimization/96931] " rguenth at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: asolokha at gmx dot com @ 2020-09-04  6:50 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 96931
           Summary: [11 Regression] ICE in add_phi_arg, at
                    tree-phinodes.c:359
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: asolokha at gmx dot com
  Target Milestone: ---

gcc-11.0.0-alpha20200830 snapshot (g:6ccadc4c0486ff011a32c74de1a31148acb3cbe2)
ICEs when compiling the following testcase w/ -O1 -fpredictive-commoning
-fno-tree-loop-im:

int bl;

void
p3 (void);

void __attribute__ ((returns_twice))
ie (void)
{
  p3 ();

  bl = 0;
  for (;;)
    ++bl;

  ie ();
}

% gcc-11.0.0 -O1 -fpredictive-commoning -fno-tree-loop-im -c d8kidanm.c
during GIMPLE pass: pcom
d8kidanm.c: In function 'ie':
d8kidanm.c:7:1: internal compiler error: in add_phi_arg, at tree-phinodes.c:359
    7 | ie (void)
      | ^~
0x6b7058 add_phi_arg(gphi*, tree_node*, edge_def*, unsigned int)
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200830/work/gcc-11-20200830/gcc/tree-phinodes.c:359
0xe41fd0 initialize_root_vars_lm
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200830/work/gcc-11-20200830/gcc/tree-predcom.c:1969
0xe41fd0 execute_load_motion
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200830/work/gcc-11-20200830/gcc/tree-predcom.c:2001
0xe41fd0 execute_pred_commoning
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200830/work/gcc-11-20200830/gcc/tree-predcom.c:2265
0xe45897 tree_predictive_commoning_loop
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200830/work/gcc-11-20200830/gcc/tree-predcom.c:3308
0xe45897 tree_predictive_commoning()
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200830/work/gcc-11-20200830/gcc/tree-predcom.c:3333

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

* [Bug tree-optimization/96931] [11 Regression] ICE in add_phi_arg, at tree-phinodes.c:359
  2020-09-04  6:50 [Bug tree-optimization/96931] New: [11 Regression] ICE in add_phi_arg, at tree-phinodes.c:359 asolokha at gmx dot com
@ 2020-09-04  7:49 ` rguenth at gcc dot gnu.org
  2020-09-04  8:26 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-09-04  7:49 UTC (permalink / raw)
  To: gcc-bugs

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

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
   Last reconfirmed|                            |2020-09-04
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |ASSIGNED
   Target Milestone|---                         |11.0

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Mine.

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

* [Bug tree-optimization/96931] [11 Regression] ICE in add_phi_arg, at tree-phinodes.c:359
  2020-09-04  6:50 [Bug tree-optimization/96931] New: [11 Regression] ICE in add_phi_arg, at tree-phinodes.c:359 asolokha at gmx dot com
  2020-09-04  7:49 ` [Bug tree-optimization/96931] " rguenth at gcc dot gnu.org
@ 2020-09-04  8:26 ` rguenth at gcc dot gnu.org
  2020-09-04  8:34 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-09-04  8:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
diff --git a/gcc/tree-predcom.c b/gcc/tree-predcom.c
index b1d6e63559c..af71c269f4b 100644
--- a/gcc/tree-predcom.c
+++ b/gcc/tree-predcom.c
@@ -1960,7 +1960,8 @@ initialize_root_vars_lm (class loop *loop, dref root,
bool written,

   init = force_gimple_operand (init, &stmts, written, NULL_TREE);
   if (stmts)
-    gsi_insert_seq_on_edge_immediate (entry, stmts);
+    if (gsi_insert_seq_on_edge_immediate (entry, stmts))
+      entry = loop_preheader_edge (loop);

   if (written)
     {


guess even with simple preheaders passes need to not assume inserting
on the entry edge will not split it (the call in the preheader ends the BB
because we've had returns_twice functions).

Now the ie() call was removed and so was the abnormal edge from p3() so
likely gimple_call_ctrl_altering_p should have been cleared from it which
would be a missed optimization.  Thus an alternative fix is there.

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

* [Bug tree-optimization/96931] [11 Regression] ICE in add_phi_arg, at tree-phinodes.c:359
  2020-09-04  6:50 [Bug tree-optimization/96931] New: [11 Regression] ICE in add_phi_arg, at tree-phinodes.c:359 asolokha at gmx dot com
  2020-09-04  7:49 ` [Bug tree-optimization/96931] " rguenth at gcc dot gnu.org
  2020-09-04  8:26 ` rguenth at gcc dot gnu.org
@ 2020-09-04  8:34 ` rguenth at gcc dot gnu.org
  2020-09-04 10:23 ` cvs-commit at gcc dot gnu.org
  2020-09-04 10:23 ` rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-09-04  8:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
So the testcase only triggers on trunk because store commoning is new there and
it transforms (interestingly!)

  <bb 2> [local count: 10631108]:
  p3 ();
  bl = 0;

  <bb 3> [local count: 1073741824]:
  bl.0_1 = bl;
  _2 = bl.0_1 + 1;
  bl = _2;
  goto <bb 3>; [100.00%]

to

  <bb 2> [local count: 10631108]:
  p3 ();

  <bb 3> [local count: 1073741824]:
  # _8 = PHI <0(2), _2(3)>
  bl = _8;
  bl.0_1 = bl;
  _2 = bl.0_1 + 1;
  goto <bb 3>; [100.00%]

which predcom tries to "improve" to

  <bb 2> [local count: 10631108]:
  p3 ();
  _10 = bl;

  <bb 3> [local count: 1073741824]:
  # _8 = PHI <0(2), _2(4)>
  # bl_lsm0.3_7 = PHI <_10(2), bl_lsm0.3_6(4)>
  bl = _8;
  bl_lsm0.3_6 = _8;
  bl.0_1 = bl_lsm0.3_6;
  _2 = bl.0_1 + 1;

  <bb 4> [local count: 1073741824]:
  goto <bb 3>; [100.00%]

so the situation is quite arcane and eventually not worth fixing on branches.

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

* [Bug tree-optimization/96931] [11 Regression] ICE in add_phi_arg, at tree-phinodes.c:359
  2020-09-04  6:50 [Bug tree-optimization/96931] New: [11 Regression] ICE in add_phi_arg, at tree-phinodes.c:359 asolokha at gmx dot com
                   ` (2 preceding siblings ...)
  2020-09-04  8:34 ` rguenth at gcc dot gnu.org
@ 2020-09-04 10:23 ` cvs-commit at gcc dot gnu.org
  2020-09-04 10:23 ` rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-09-04 10:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 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:fab77644842869adc8871e133e4c3f4c35b2b245

commit r11-3009-gfab77644842869adc8871e133e4c3f4c35b2b245
Author: Richard Biener <rguenther@suse.de>
Date:   Fri Sep 4 12:18:38 2020 +0200

    tree-optimization/96931 - clear ctrl-altering flag more aggressively

    The testcase shows that we fail to clear gimple_call_ctrl_altering_p
    when the last abnormal edge goes away, causing an edge insert to
    a loop header edge when we have preheaders to split the edge
    unnecessarily.

    The following addresses this by more aggressively clearing the
    flag in cleanup_call_ctrl_altering_flag.

    2020-09-04  Richard Biener  <rguenther@suse.de>

            PR tree-optimization/96931
            * tree-cfgcleanup.c (cleanup_call_ctrl_altering_flag): If
            there's a fallthru edge and no abnormal edge the call is
            no longer control-altering.
            (cleanup_control_flow_bb): Pass down the BB to
            cleanup_call_ctrl_altering_flag.

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

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

* [Bug tree-optimization/96931] [11 Regression] ICE in add_phi_arg, at tree-phinodes.c:359
  2020-09-04  6:50 [Bug tree-optimization/96931] New: [11 Regression] ICE in add_phi_arg, at tree-phinodes.c:359 asolokha at gmx dot com
                   ` (3 preceding siblings ...)
  2020-09-04 10:23 ` cvs-commit at gcc dot gnu.org
@ 2020-09-04 10:23 ` rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-09-04 10:23 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2020-09-04 10:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-04  6:50 [Bug tree-optimization/96931] New: [11 Regression] ICE in add_phi_arg, at tree-phinodes.c:359 asolokha at gmx dot com
2020-09-04  7:49 ` [Bug tree-optimization/96931] " rguenth at gcc dot gnu.org
2020-09-04  8:26 ` rguenth at gcc dot gnu.org
2020-09-04  8:34 ` rguenth at gcc dot gnu.org
2020-09-04 10:23 ` cvs-commit at gcc dot gnu.org
2020-09-04 10:23 ` 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).