public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/97741] New: ICE: verify_gimple failed with "-Os -fno-toplevel-reorder -fno-tree-ccp -fno-tree-fre"
@ 2020-11-06 10:15 suochenyao at 163 dot com
  2020-11-06 10:20 ` [Bug tree-optimization/97741] [11 Regression] ICE: verify_gimple failed with "-Os -fno-toplevel-reorder -fno-tree-ccp -fno-tree-fre" since r11-4724 jakub at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: suochenyao at 163 dot com @ 2020-11-06 10:15 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 97741
           Summary: ICE: verify_gimple failed with "-Os
                    -fno-toplevel-reorder -fno-tree-ccp -fno-tree-fre"
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: suochenyao at 163 dot com
  Target Milestone: ---

*******************************************************************************
OS and Platform:
CentOS Linux release 7.8.2003 (Core), x86_64 GNU/Linux
*******************************************************************************
Program:
short a = 0;
long b = 0;
char c = 0;
void d() {
  int e = 0;
f:
  for (a = 6; a;)
    c = e;
  e = 0;
  for (; e == 20; ++e)
    for (; b;)
      goto f;
}
int main() { return 0; }
*******************************************************************************
gcc version:
$ gcc -v
Using built-in specs.
COLLECT_GCC=/home/suocy/bin/gcc-dev/bin/gcc
COLLECT_LTO_WRAPPER=/home/suocy/bin/gcc-dev/libexec/gcc/x86_64-pc-linux-gnu/11.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --prefix=/home/suocy/bin/gcc-dev
--disable-multilib --enable-languages=c,c++
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.0.0 20201106 (experimental) (GCC)
*******************************************************************************
Command Lines:
$ gcc -Wall -Wextra -fno-strict-aliasing -fwrapv -Os -fno-toplevel-reorder
-fno-tree-ccp -fno-tree-fre a.c
a.c: In function ‘d’:
a.c:14:1: error: invalid types in nop conversion
   14 | int main() { return 0; }
      | ^~~
char
<<< error >>>
_1 = (char) _4;
during GIMPLE pass: evrp
a.c:14:1: internal compiler error: verify_gimple failed
0xe1a2ba verify_gimple_in_cfg(function*, bool)
        ../../gcc/tree-cfg.c:5461
0xcf7e17 execute_function_todo
        ../../gcc/passes.c:2039
0xcf887e execute_todo
        ../../gcc/passes.c:2093
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

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

* [Bug tree-optimization/97741] [11 Regression] ICE: verify_gimple failed with "-Os -fno-toplevel-reorder -fno-tree-ccp -fno-tree-fre" since r11-4724
  2020-11-06 10:15 [Bug tree-optimization/97741] New: ICE: verify_gimple failed with "-Os -fno-toplevel-reorder -fno-tree-ccp -fno-tree-fre" suochenyao at 163 dot com
@ 2020-11-06 10:20 ` jakub at gcc dot gnu.org
  2020-11-06 10:38 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-11-06 10:20 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |11.0
                 CC|                            |jakub at gcc dot gnu.org
   Last reconfirmed|                            |2020-11-06
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
            Summary|ICE: verify_gimple failed   |[11 Regression] ICE:
                   |with "-Os                   |verify_gimple failed with
                   |-fno-toplevel-reorder       |"-Os -fno-toplevel-reorder
                   |-fno-tree-ccp               |-fno-tree-ccp
                   |-fno-tree-fre"              |-fno-tree-fre" since
                   |                            |r11-4724

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r11-4724-ge86fd6a17cdb26710d1f13c9a47a3878c76028f9

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

* [Bug tree-optimization/97741] [11 Regression] ICE: verify_gimple failed with "-Os -fno-toplevel-reorder -fno-tree-ccp -fno-tree-fre" since r11-4724
  2020-11-06 10:15 [Bug tree-optimization/97741] New: ICE: verify_gimple failed with "-Os -fno-toplevel-reorder -fno-tree-ccp -fno-tree-fre" suochenyao at 163 dot com
  2020-11-06 10:20 ` [Bug tree-optimization/97741] [11 Regression] ICE: verify_gimple failed with "-Os -fno-toplevel-reorder -fno-tree-ccp -fno-tree-fre" since r11-4724 jakub at gcc dot gnu.org
@ 2020-11-06 10:38 ` rguenth at gcc dot gnu.org
  2020-11-06 16:00 ` amacleod at redhat dot com
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-11-06 10:38 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1

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

* [Bug tree-optimization/97741] [11 Regression] ICE: verify_gimple failed with "-Os -fno-toplevel-reorder -fno-tree-ccp -fno-tree-fre" since r11-4724
  2020-11-06 10:15 [Bug tree-optimization/97741] New: ICE: verify_gimple failed with "-Os -fno-toplevel-reorder -fno-tree-ccp -fno-tree-fre" suochenyao at 163 dot com
  2020-11-06 10:20 ` [Bug tree-optimization/97741] [11 Regression] ICE: verify_gimple failed with "-Os -fno-toplevel-reorder -fno-tree-ccp -fno-tree-fre" since r11-4724 jakub at gcc dot gnu.org
  2020-11-06 10:38 ` rguenth at gcc dot gnu.org
@ 2020-11-06 16:00 ` amacleod at redhat dot com
  2020-11-06 16:09 ` amacleod at redhat dot com
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: amacleod at redhat dot com @ 2020-11-06 16:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Macleod <amacleod at redhat dot com> ---
Created attachment 49517
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49517&action=edit
don't lose info already in the global range

The problem here is the IL being changed by propagation under to covers
sometimes loses information.

The first thing examined is:
   e_4 = PHI <0(2), e_8(6)>
and the ranger goes off on the backedge to block 6 and eventually determines
that the edge 6->2 can never be executed, and thus e_8 is undefined on that
edge, which means the range of the PHI can be determined to be [0,0], and can
thus be folded.

Later on the propagator visits the blocks this originates in and sees
 e_8 = PHI <e_5(7)>

which is fed by the sequence:
<bb 7> :
  b.1_3 = b;
  if (b.1_3 != 0)
    goto <bb 6>; [INV]

<bb 8> :
  e_12 = e_5 + 1;

<bb 9> :
  # e_5 = PHI <0(5), e_12(8)>
  if (e_5 == 20)
    goto <bb 7>; [INV]


The ranger had figured out that although the branch says e_5 must be 20 on the
edge from bb5,it can only get to this code if it is 20 AND goes thru the e_12 =
e_5 + 1, which means e_12 must only be [21, 21]  which makes the whole thing
undefined.. and it is. it can never happen. 

However, when the propagator later visits stmts, and we get to 
e_12 = e_5 + 1;
when this is re-evaluated, e_5 is undefined and rather than propagating  e_12
as undefined, we decided a while ago to treat undefined as VARYING when doing
math.. we change e_12 to VARYING now, even tho we had earlier decided it was
[21,21]

This has ripple effects that eventually results in deciding that e_5 must be 
[20,20] coming from bb 7, it replaces that first PHI:
e_8 = PHI <e_5(7)>
with e_8 = PHI <20(7)>

when we then ask for the range of e_4 again at a use:
<bb 4> :
  _1 = (char) e_4;

e_4 = PHI <0(2), e_8(6)>
e_8 is now hardwired to [20,20] so it now recalculates e_4 to be
[0,0][20,20] instead of 0, and the engine does not fold the statement.

which ends up leaving e_4 in the IL with no definition.

THe easiest way to fix this sort of thing is to recognize that with the IL
changing under the covers in ways not really controlled by the ranger, we
should keep the previous value we defined, and refine it as we go along rather
than fully recalculating it.   

I think this will resolve an entire class of issues until we change the way we
propagate things, or revisit the slightly schizophrenic interpretation of
undefined.  The original RVRP pass simply propagated values via the
immediate-use chains, so the IL always reflected exactly what it knew. 

The attached patch is currently being tested.

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

* [Bug tree-optimization/97741] [11 Regression] ICE: verify_gimple failed with "-Os -fno-toplevel-reorder -fno-tree-ccp -fno-tree-fre" since r11-4724
  2020-11-06 10:15 [Bug tree-optimization/97741] New: ICE: verify_gimple failed with "-Os -fno-toplevel-reorder -fno-tree-ccp -fno-tree-fre" suochenyao at 163 dot com
                   ` (2 preceding siblings ...)
  2020-11-06 16:00 ` amacleod at redhat dot com
@ 2020-11-06 16:09 ` amacleod at redhat dot com
  2020-11-06 16:11 ` amacleod at redhat dot com
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: amacleod at redhat dot com @ 2020-11-06 16:09 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Macleod <amacleod at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |zhendong.su at inf dot ethz.ch

--- Comment #3 from Andrew Macleod <amacleod at redhat dot com> ---
*** Bug 97737 has been marked as a duplicate of this bug. ***

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

* [Bug tree-optimization/97741] [11 Regression] ICE: verify_gimple failed with "-Os -fno-toplevel-reorder -fno-tree-ccp -fno-tree-fre" since r11-4724
  2020-11-06 10:15 [Bug tree-optimization/97741] New: ICE: verify_gimple failed with "-Os -fno-toplevel-reorder -fno-tree-ccp -fno-tree-fre" suochenyao at 163 dot com
                   ` (3 preceding siblings ...)
  2020-11-06 16:09 ` amacleod at redhat dot com
@ 2020-11-06 16:11 ` amacleod at redhat dot com
  2020-11-06 19:27 ` cvs-commit at gcc dot gnu.org
  2020-11-06 19:30 ` amacleod at redhat dot com
  6 siblings, 0 replies; 8+ messages in thread
From: amacleod at redhat dot com @ 2020-11-06 16:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Andrew Macleod <amacleod at redhat dot com> ---
btw, the resulting code for this function is cleaned up a lot:
  <bb 2> :
  a = 6;
  goto <bb 4>; [INV]

  <bb 3> :
  c = 0;

  <bb 4> :
  a.0_2 = a;
  if (a.0_2 != 0)
    goto <bb 3>; [INV]
  else
    goto <bb 5>; [INV]

  <bb 5> :
  # e_5 = PHI <0(4)>
  return;

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

* [Bug tree-optimization/97741] [11 Regression] ICE: verify_gimple failed with "-Os -fno-toplevel-reorder -fno-tree-ccp -fno-tree-fre" since r11-4724
  2020-11-06 10:15 [Bug tree-optimization/97741] New: ICE: verify_gimple failed with "-Os -fno-toplevel-reorder -fno-tree-ccp -fno-tree-fre" suochenyao at 163 dot com
                   ` (4 preceding siblings ...)
  2020-11-06 16:11 ` amacleod at redhat dot com
@ 2020-11-06 19:27 ` cvs-commit at gcc dot gnu.org
  2020-11-06 19:30 ` amacleod at redhat dot com
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-11-06 19:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Andrew Macleod <amacleod@gcc.gnu.org>:

https://gcc.gnu.org/g:129e1a8a96d140150705fab30d25afb464eb1d99

commit r11-4795-g129e1a8a96d140150705fab30d25afb464eb1d99
Author: Andrew MacLeod <amacleod@redhat.com>
Date:   Fri Nov 6 14:14:46 2020 -0500

    Combine new calculated ranges with existing range.

    When a range is recalculated, retain what was previously known as IL
changes
    can produce different results from un-executed code.   This also paves
    the way for external injection of ranges.

            gcc/
            PR tree-optimization/97737
            PR tree-optimization/97741
            * gimple-range.cc: (gimple_ranger::range_of_stmt): Intersect newly
            calculated ranges with the existing known global range.
            gcc/testsuite/
            * gcc.dg/pr97737.c: New.
            * gcc.dg/pr97741.c: New.

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

* [Bug tree-optimization/97741] [11 Regression] ICE: verify_gimple failed with "-Os -fno-toplevel-reorder -fno-tree-ccp -fno-tree-fre" since r11-4724
  2020-11-06 10:15 [Bug tree-optimization/97741] New: ICE: verify_gimple failed with "-Os -fno-toplevel-reorder -fno-tree-ccp -fno-tree-fre" suochenyao at 163 dot com
                   ` (5 preceding siblings ...)
  2020-11-06 19:27 ` cvs-commit at gcc dot gnu.org
@ 2020-11-06 19:30 ` amacleod at redhat dot com
  6 siblings, 0 replies; 8+ messages in thread
From: amacleod at redhat dot com @ 2020-11-06 19:30 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Macleod <amacleod at redhat dot com> changed:

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

--- Comment #6 from Andrew Macleod <amacleod at redhat dot com> ---
fixed.

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

end of thread, other threads:[~2020-11-06 19:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-06 10:15 [Bug tree-optimization/97741] New: ICE: verify_gimple failed with "-Os -fno-toplevel-reorder -fno-tree-ccp -fno-tree-fre" suochenyao at 163 dot com
2020-11-06 10:20 ` [Bug tree-optimization/97741] [11 Regression] ICE: verify_gimple failed with "-Os -fno-toplevel-reorder -fno-tree-ccp -fno-tree-fre" since r11-4724 jakub at gcc dot gnu.org
2020-11-06 10:38 ` rguenth at gcc dot gnu.org
2020-11-06 16:00 ` amacleod at redhat dot com
2020-11-06 16:09 ` amacleod at redhat dot com
2020-11-06 16:11 ` amacleod at redhat dot com
2020-11-06 19:27 ` cvs-commit at gcc dot gnu.org
2020-11-06 19:30 ` amacleod at redhat 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).