public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/101496] New: ice during GIMPLE pass: evrp
@ 2021-07-18  7:42 dcb314 at hotmail dot com
  2021-07-18  7:51 ` [Bug tree-optimization/101496] [12 Regression] " pinskia at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: dcb314 at hotmail dot com @ 2021-07-18  7:42 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101496
           Summary: ice during GIMPLE pass: evrp
           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: ---

This C source code:

int c_1, li_2, us_3, func_14_s_5;

void func_14() {
  {
    unsigned uli_8 = 0;
  lbl1806324B:
    if (uli_8 /= us_3 |= func_14_s_5 < 0 | func_14_s_5 != c_1) {
      uli_8 += c_1 >= us_3;
      if (uli_8)
        ;
      else
        li_2 &&func_14_s_5 <= c_1 ?: 0;
      long *ptr_9 = &uli_8;
    }
  }
  goto lbl1806324B;
}

with recent gcc trunk does this:

$ /home/dcb/gcc/results/bin/gcc -c -O2 bug736.c 2>&1 | more
bug736.c: In function ‘func_14’:
bug736.c:13:21: warning: initialization of ‘long int *’ from incompatible point
er type ‘unsigned int *’ [-Wincompatible-pointer-types]
   13 |       long *ptr_9 = &uli_8;
      |                     ^
during GIMPLE pass: evrp
bug736.c:17:1: internal compiler error: in fold_cond, at vr-values.c:3482
   17 | }
      | ^
0x7d8685 simplify_using_ranges::fold_cond(gcond*)
        ../../trunk.git/gcc/vr-values.c:3482
0x1334c24 simplify_using_ranges::simplify_cond_using_ranges_1(gcond*)
        ../../trunk.git/gcc/vr-values.c:3517
0x1160886 substitute_and_fold_dom_walker::before_dom_children(basic_block_def*)
        ../../trunk.git/gcc/tree-ssa-propagate.c:870
0x1ad3e77 dom_walker::walk(basic_block_def*)
        ../../trunk.git/gcc/domwalk.c:309

Bug first seems to occur sometime after git hash 42ff474e28fa3c85
but before cca7eb8f7cc157ed.

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

* [Bug tree-optimization/101496] [12 Regression] ice during GIMPLE pass: evrp
  2021-07-18  7:42 [Bug c/101496] New: ice during GIMPLE pass: evrp dcb314 at hotmail dot com
@ 2021-07-18  7:51 ` pinskia at gcc dot gnu.org
  2021-07-18  7:53 ` pinskia at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-18  7:51 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |12.0

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

* [Bug tree-optimization/101496] [12 Regression] ice during GIMPLE pass: evrp
  2021-07-18  7:42 [Bug c/101496] New: ice during GIMPLE pass: evrp dcb314 at hotmail dot com
  2021-07-18  7:51 ` [Bug tree-optimization/101496] [12 Regression] " pinskia at gcc dot gnu.org
@ 2021-07-18  7:53 ` pinskia at gcc dot gnu.org
  2021-07-18  9:12 ` dcb314 at hotmail dot com
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-18  7:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to David Binderman from comment #0)
> Bug first seems to occur sometime after git hash 42ff474e28fa3c85
> but before cca7eb8f7cc157ed.

So between r12-1856 and r12-1917.

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

* [Bug tree-optimization/101496] [12 Regression] ice during GIMPLE pass: evrp
  2021-07-18  7:42 [Bug c/101496] New: ice during GIMPLE pass: evrp dcb314 at hotmail dot com
  2021-07-18  7:51 ` [Bug tree-optimization/101496] [12 Regression] " pinskia at gcc dot gnu.org
  2021-07-18  7:53 ` pinskia at gcc dot gnu.org
@ 2021-07-18  9:12 ` dcb314 at hotmail dot com
  2021-07-18  9:44 ` dcb314 at hotmail dot com
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: dcb314 at hotmail dot com @ 2021-07-18  9:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from David Binderman <dcb314 at hotmail dot com> ---
(In reply to Andrew Pinski from comment #1)
> (In reply to David Binderman from comment #0)
> > Bug first seems to occur sometime after git hash 42ff474e28fa3c85
> > but before cca7eb8f7cc157ed.
> 
> So between r12-1856 and r12-1917.

There are about 61 revisions, so git bisect offers 32638d4975f2768b
for testing.

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

* [Bug tree-optimization/101496] [12 Regression] ice during GIMPLE pass: evrp
  2021-07-18  7:42 [Bug c/101496] New: ice during GIMPLE pass: evrp dcb314 at hotmail dot com
                   ` (2 preceding siblings ...)
  2021-07-18  9:12 ` dcb314 at hotmail dot com
@ 2021-07-18  9:44 ` dcb314 at hotmail dot com
  2021-07-18  9:59 ` dcb314 at hotmail dot com
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: dcb314 at hotmail dot com @ 2021-07-18  9:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from David Binderman <dcb314 at hotmail dot com> ---
(In reply to David Binderman from comment #2)
> (In reply to Andrew Pinski from comment #1)
> > (In reply to David Binderman from comment #0)
> > > Bug first seems to occur sometime after git hash 42ff474e28fa3c85
> > > but before cca7eb8f7cc157ed.
> > 
> > So between r12-1856 and r12-1917.
> 
> There are about 61 revisions, so git bisect offers 32638d4975f2768b
> for testing.

Seems good, so trying ba4b83c3e3bd44448a85e3771b91ae39421d9dd7

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

* [Bug tree-optimization/101496] [12 Regression] ice during GIMPLE pass: evrp
  2021-07-18  7:42 [Bug c/101496] New: ice during GIMPLE pass: evrp dcb314 at hotmail dot com
                   ` (3 preceding siblings ...)
  2021-07-18  9:44 ` dcb314 at hotmail dot com
@ 2021-07-18  9:59 ` dcb314 at hotmail dot com
  2021-07-18 10:28 ` dcb314 at hotmail dot com
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: dcb314 at hotmail dot com @ 2021-07-18  9:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from David Binderman <dcb314 at hotmail dot com> ---
(In reply to David Binderman from comment #3)
> (In reply to David Binderman from comment #2)
> > (In reply to Andrew Pinski from comment #1)
> > > (In reply to David Binderman from comment #0)
> > > > Bug first seems to occur sometime after git hash 42ff474e28fa3c85
> > > > but before cca7eb8f7cc157ed.
> > > 
> > > So between r12-1856 and r12-1917.
> > 
> > There are about 61 revisions, so git bisect offers 32638d4975f2768b
> > for testing.
> 
> Seems good, so trying ba4b83c3e3bd44448a85e3771b91ae39421d9dd7

Seems good, so trying 0c06e46a81d86d70

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

* [Bug tree-optimization/101496] [12 Regression] ice during GIMPLE pass: evrp
  2021-07-18  7:42 [Bug c/101496] New: ice during GIMPLE pass: evrp dcb314 at hotmail dot com
                   ` (4 preceding siblings ...)
  2021-07-18  9:59 ` dcb314 at hotmail dot com
@ 2021-07-18 10:28 ` dcb314 at hotmail dot com
  2021-07-19  6:36 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: dcb314 at hotmail dot com @ 2021-07-18 10:28 UTC (permalink / raw)
  To: gcc-bugs

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

David Binderman <dcb314 at hotmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |amacleod at redhat dot com

--- Comment #5 from David Binderman <dcb314 at hotmail dot com> ---
(In reply to David Binderman from comment #4)
> (In reply to David Binderman from comment #3)
> > (In reply to David Binderman from comment #2)
> > > (In reply to Andrew Pinski from comment #1)
> > > > (In reply to David Binderman from comment #0)
> > > > > Bug first seems to occur sometime after git hash 42ff474e28fa3c85
> > > > > but before cca7eb8f7cc157ed.
> > > > 
> > > > So between r12-1856 and r12-1917.
> > > 
> > > There are about 61 revisions, so git bisect offers 32638d4975f2768b
> > > for testing.
> > 
> > Seems good, so trying ba4b83c3e3bd44448a85e3771b91ae39421d9dd7
> 
> Seems good, so trying 0c06e46a81d86d70

Bug seems to be between a7e655ae4016eaf04e261ff32fc67a14ebb0e329
and cca7eb8f7cc157ed1b351cbaa10a4066f8065c3a. Andrew Macleod is
the author of three of those four revisions, so adding this person
for additional comment.

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

* [Bug tree-optimization/101496] [12 Regression] ice during GIMPLE pass: evrp
  2021-07-18  7:42 [Bug c/101496] New: ice during GIMPLE pass: evrp dcb314 at hotmail dot com
                   ` (5 preceding siblings ...)
  2021-07-18 10:28 ` dcb314 at hotmail dot com
@ 2021-07-19  6:36 ` rguenth at gcc dot gnu.org
  2021-07-19 18:44 ` amacleod at redhat dot com
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-19  6:36 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

* [Bug tree-optimization/101496] [12 Regression] ice during GIMPLE pass: evrp
  2021-07-18  7:42 [Bug c/101496] New: ice during GIMPLE pass: evrp dcb314 at hotmail dot com
                   ` (6 preceding siblings ...)
  2021-07-19  6:36 ` rguenth at gcc dot gnu.org
@ 2021-07-19 18:44 ` amacleod at redhat dot com
  2021-07-22 12:53 ` cvs-commit at gcc dot gnu.org
  2021-07-22 13:07 ` amacleod at redhat dot com
  9 siblings, 0 replies; 11+ messages in thread
From: amacleod at redhat dot com @ 2021-07-19 18:44 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Macleod <amacleod at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-07-19
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1

--- Comment #6 from Andrew Macleod <amacleod at redhat dot com> ---
This test case has unreachable code in it. 
This issue comes down to

  func_14_s_5.0_1 = func_14_s_5;
  _2 = func_14_s_5.0_1 < 0;
  c_1.2_4 = c_1;
  _5 = func_14_s_5.0_1 != c_1.2_4;
  _6 = _2 | _5;
  _7 = (int) _6;
  us_3.3_8 = us_3;
  _9 = _7 | us_3.3_8;
  us_3 = _9;
  us_3.6_11 = (unsigned int) _9;
  if (us_3.6_11 == 0)
    goto <bb 4>; [INV]
  else
    goto <bb 9>; [INV]

We determine that in order for us_3.6_11 to be == 0 and take the branch to bb4,
that _9, _7, _2 and _5 must all also be 0.   This means that
_5 = func_14_s_5.0_1 != c_1.2_4;
must be false, which then means that
  func_14_s_5.0_1 == c_1.2_4

_2 being false also means func_14_s_5.0_1 >= 0 or  [0, +INF]

Next:
  <bb 4> :
  _16 = c_1.2_4 >= _9;
  _17 = (unsigned int) _16;
  if (_17 != 0)
    goto <bb 9>; [INV]
  else
    goto <bb 5>; [INV]

to take the branch to bb5, c_1.2_4 must be < _9, (_9 is known to be [0,0]..
meaning its range would be [-INF, -1].

we arent fully exploiting equivalences yet, so we dont fold this branch, even
though we potentially could.  With  func_14_s_5.0_1 == c_1.2_4, that means
c_1.2_4 will enter this branch with the range [0, +INF] which means it can
never be < _9 and we will always branch to BB 9.   We currently miss that fold,
so don't realize yet that bb_5 in unreachable.

but this leads us to the next branch, which is causing the problem:
  <bb 6> :
  if (func_14_s_5.0_1 <= c_1.2_4)
    goto <bb 8>; [INV]
  else
    goto <bb 7>; [INV]

Ranger first tries to fold with relations, so it determines that this is always
TRUE since func_14_s_5.0_1 == c_1.2_4.  The simplification code still has
legacy support in it, and confirms that whatever we come up with the with new
range API matches the old code.  The old code says   
 func_14_s_5.0_1 == [0, +INF],  and c_1.2_4 == [-INF, -1], so this branch is
never taken.. result is FALSE.
Now an assert it tripped saying the 2 approaches do not agree on which edge
would be taken. The code is unreachable.. so it doesnt really matter.

To fix this, I am tweaking the simplification code for now to simply use the
value the new API returns, if it returns one.
Otherwise, it then checks the old API and the only time it is allowed to find a
taken edge is if the NEW API says the fold is undefined. 

Eventually we can remove that too, but for now, I leave it as a sanity check to
ensure we dont find something important, and it is harmless for the OLD API
code to remove unreachable code.


This function eventually folds to
  <bb 2> [local count: 10631108]:

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

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

* [Bug tree-optimization/101496] [12 Regression] ice during GIMPLE pass: evrp
  2021-07-18  7:42 [Bug c/101496] New: ice during GIMPLE pass: evrp dcb314 at hotmail dot com
                   ` (7 preceding siblings ...)
  2021-07-19 18:44 ` amacleod at redhat dot com
@ 2021-07-22 12:53 ` cvs-commit at gcc dot gnu.org
  2021-07-22 13:07 ` amacleod at redhat dot com
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-07-22 12:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 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:e58093276a6e319c2a6d9f02e343fbf8400dab60

commit r12-2464-ge58093276a6e319c2a6d9f02e343fbf8400dab60
Author: Andrew MacLeod <amacleod@redhat.com>
Date:   Mon Jul 19 14:02:57 2021 -0400

    Only call vrp_visit_cond_stmt if range_of_stmt doesn't resolve to a const.

    Eevntually all functionality will be subsumed.  Until then, call it only
    if needed.

            gcc/
            PR tree-optimization/101496
            * vr-values.c (simplify_using_ranges::fold_cond): Call
range_of_stmt
            first, then vrp_visit_cond_Stmt.

            gcc/testsuite
            * gcc.dg/pr101496.c: New.

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

* [Bug tree-optimization/101496] [12 Regression] ice during GIMPLE pass: evrp
  2021-07-18  7:42 [Bug c/101496] New: ice during GIMPLE pass: evrp dcb314 at hotmail dot com
                   ` (8 preceding siblings ...)
  2021-07-22 12:53 ` cvs-commit at gcc dot gnu.org
@ 2021-07-22 13:07 ` amacleod at redhat dot com
  9 siblings, 0 replies; 11+ messages in thread
From: amacleod at redhat dot com @ 2021-07-22 13:07 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Macleod <amacleod at redhat dot com> changed:

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

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

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

end of thread, other threads:[~2021-07-22 13:07 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-18  7:42 [Bug c/101496] New: ice during GIMPLE pass: evrp dcb314 at hotmail dot com
2021-07-18  7:51 ` [Bug tree-optimization/101496] [12 Regression] " pinskia at gcc dot gnu.org
2021-07-18  7:53 ` pinskia at gcc dot gnu.org
2021-07-18  9:12 ` dcb314 at hotmail dot com
2021-07-18  9:44 ` dcb314 at hotmail dot com
2021-07-18  9:59 ` dcb314 at hotmail dot com
2021-07-18 10:28 ` dcb314 at hotmail dot com
2021-07-19  6:36 ` rguenth at gcc dot gnu.org
2021-07-19 18:44 ` amacleod at redhat dot com
2021-07-22 12:53 ` cvs-commit at gcc dot gnu.org
2021-07-22 13:07 ` 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).