public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/97359] New: ice in logical_combine, at gimple-range-gori.cc:754
@ 2020-10-09 20:43 dcb314 at hotmail dot com
  2020-10-09 20:47 ` [Bug c/97359] " dcb314 at hotmail dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: dcb314 at hotmail dot com @ 2020-10-09 20:43 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 97359
           Summary: ice in logical_combine, at gimple-range-gori.cc:754
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dcb314 at hotmail dot com
  Target Milestone: ---

The attached C code, when compiled by recent gcc trunk
and compiler flag -O2, does this:

$ ../results/bin/gcc -c -O2 -w bug651.c
during GIMPLE pass: evrp
bug651.c: In function ‘func_14’:
bug651.c:12278:1: internal compiler error: in logical_combine, at
gimple-range-gori.cc:754
12278 | }
      | ^
0x18d8f56 gori_compute::logical_combine(irange&, tree_code, irange const&,
tf_range const&, tf_range const&)
        ../../trunk.git/gcc/gimple-range-gori.cc:754
0x18da9e2 gori_compute_cache::cache_stmt(gimple*)
        ../../trunk.git/gcc/gimple-range-gori.cc:1314
0x18da6c4 gori_compute_cache::compute_operand_range(irange&, gimple*, irange
const&, tree_node*)
        ../../trunk.git/gcc/gimple-range-gori.cc:1279
0x18d881e gori_compute::compute_operand1_range(irange&, gimple*, irange const&,
tree_node*)

I'll have a go at reducing the code.

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

* [Bug c/97359] ice in logical_combine, at gimple-range-gori.cc:754
  2020-10-09 20:43 [Bug c/97359] New: ice in logical_combine, at gimple-range-gori.cc:754 dcb314 at hotmail dot com
@ 2020-10-09 20:47 ` dcb314 at hotmail dot com
  2020-10-09 20:54 ` dcb314 at hotmail dot com
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: dcb314 at hotmail dot com @ 2020-10-09 20:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from David Binderman <dcb314 at hotmail dot com> ---
The code seems to break gcc trunk sometime between 20201006 and 20201007.

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

* [Bug c/97359] ice in logical_combine, at gimple-range-gori.cc:754
  2020-10-09 20:43 [Bug c/97359] New: ice in logical_combine, at gimple-range-gori.cc:754 dcb314 at hotmail dot com
  2020-10-09 20:47 ` [Bug c/97359] " dcb314 at hotmail dot com
@ 2020-10-09 20:54 ` dcb314 at hotmail dot com
  2020-10-09 21:34 ` [Bug tree-optimization/97359] [11 Regression] " jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: dcb314 at hotmail dot com @ 2020-10-09 20:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from David Binderman <dcb314 at hotmail dot com> ---
The reduced C code is

typedef unsigned int uint32_t;
int a;
void b(uint32_t c) {
  uint32_t *d = &c;
  for (; a;)
    for (;; (*d %= a) / (*d > 1 > (c > 0)) ?: d)
      ;
}

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

* [Bug tree-optimization/97359] [11 Regression] ice in logical_combine, at gimple-range-gori.cc:754
  2020-10-09 20:43 [Bug c/97359] New: ice in logical_combine, at gimple-range-gori.cc:754 dcb314 at hotmail dot com
  2020-10-09 20:47 ` [Bug c/97359] " dcb314 at hotmail dot com
  2020-10-09 20:54 ` dcb314 at hotmail dot com
@ 2020-10-09 21:34 ` jakub at gcc dot gnu.org
  2020-10-10  6:50 ` aldyh at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-10-09 21:34 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|ice in logical_combine, at  |[11 Regression] ice in
                   |gimple-range-gori.cc:754    |logical_combine, at
                   |                            |gimple-range-gori.cc:754
   Target Milestone|---                         |11.0
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2020-10-09
                 CC|                            |aldyh at gcc dot gnu.org,
                   |                            |amacleod at redhat dot com,
                   |                            |jakub at gcc dot gnu.org
          Component|c                           |tree-optimization

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Since r11-3685-gfcae5121154d1c3382b056bcc2c563cedac28e74 or r11-3684 (the
latter doesn't build) in particular.

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

* [Bug tree-optimization/97359] [11 Regression] ice in logical_combine, at gimple-range-gori.cc:754
  2020-10-09 20:43 [Bug c/97359] New: ice in logical_combine, at gimple-range-gori.cc:754 dcb314 at hotmail dot com
                   ` (2 preceding siblings ...)
  2020-10-09 21:34 ` [Bug tree-optimization/97359] [11 Regression] " jakub at gcc dot gnu.org
@ 2020-10-10  6:50 ` aldyh at gcc dot gnu.org
  2020-10-10  8:26 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: aldyh at gcc dot gnu.org @ 2020-10-10  6:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Aldy Hernandez <aldyh at gcc dot gnu.org> ---
Created attachment 49340
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49340&action=edit
untested proposed patch

Untested.

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

* [Bug tree-optimization/97359] [11 Regression] ice in logical_combine, at gimple-range-gori.cc:754
  2020-10-09 20:43 [Bug c/97359] New: ice in logical_combine, at gimple-range-gori.cc:754 dcb314 at hotmail dot com
                   ` (3 preceding siblings ...)
  2020-10-10  6:50 ` aldyh at gcc dot gnu.org
@ 2020-10-10  8:26 ` cvs-commit at gcc dot gnu.org
  2020-10-10  8:28 ` aldyh at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-10-10  8:26 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:14db1dfcd18e4d2712a043bdcd3976fcfb0642c2

commit r11-3762-g14db1dfcd18e4d2712a043bdcd3976fcfb0642c2
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Sat Oct 10 08:28:52 2020 +0200

    PR97359: Do not cache relops in GORI cache.

    logical_stmt_cache::cacheable_p() returns true for relops, but
    logical_combine (which does the caching) doesn't handle them and ICEs.
    This patch fixes the inconsistency by returning false for relops.

    This was working before because even though logical_combine doesn't
    handle relops, statements with only one SSA are handled in cache_stmt,
    which seems like the only statement we've ever encountered (even through
    a full Fedora build).

            lhs = s_5 > 999;

    However, with two SSA operands we ICE because logical_combine doesn't
    handle them:

            lhs = s_5 > y_8;

    We can either return false for relops in cacheable_p, or fix
    logical_combine to handle them.  The original idea was to only cache
    ANDs and ORs, so I've done the former to unbreak trunk.

    We can decide later if there was ever any benefit in caching relops.

    gcc/ChangeLog:

            PR tree-optimization/97359
            * gimple-range-gori.cc (logical_stmt_cache::cacheable_p): Only
            handle ANDs and ORs.
            (gori_compute_cache::cache_stmt): Adjust comment.

    gcc/testsuite/ChangeLog:

            * gcc.dg/pr97359.c: New test.

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

* [Bug tree-optimization/97359] [11 Regression] ice in logical_combine, at gimple-range-gori.cc:754
  2020-10-09 20:43 [Bug c/97359] New: ice in logical_combine, at gimple-range-gori.cc:754 dcb314 at hotmail dot com
                   ` (4 preceding siblings ...)
  2020-10-10  8:26 ` cvs-commit at gcc dot gnu.org
@ 2020-10-10  8:28 ` aldyh at gcc dot gnu.org
  2020-10-14 15:03 ` amacleod at redhat dot com
  2020-11-30  3:11 ` hjl.tools at gmail dot com
  7 siblings, 0 replies; 9+ messages in thread
From: aldyh at gcc dot gnu.org @ 2020-10-10  8:28 UTC (permalink / raw)
  To: gcc-bugs

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

Aldy Hernandez <aldyh at gcc dot gnu.org> changed:

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

--- Comment #6 from Aldy Hernandez <aldyh at gcc dot gnu.org> ---
fixed

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

* [Bug tree-optimization/97359] [11 Regression] ice in logical_combine, at gimple-range-gori.cc:754
  2020-10-09 20:43 [Bug c/97359] New: ice in logical_combine, at gimple-range-gori.cc:754 dcb314 at hotmail dot com
                   ` (5 preceding siblings ...)
  2020-10-10  8:28 ` aldyh at gcc dot gnu.org
@ 2020-10-14 15:03 ` amacleod at redhat dot com
  2020-11-30  3:11 ` hjl.tools at gmail dot com
  7 siblings, 0 replies; 9+ messages in thread
From: amacleod at redhat dot com @ 2020-10-14 15:03 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Andrew Macleod <amacleod at redhat dot com> ---
There is no need to cache non-logical operands. Processing a relational such as
<,>,<=,>= is a linear process, and therefore we never needed to cache them.

&& and || is exponential as we have to evaluate 
op1_true, op1_false,  op2_true,  and op2_false 
and the resulting 4 combinations...  so each logical operand can trigger 4
lookup calculations.. and when they feed into each other the on-demand lookups
become exponential quite quickly.. 

the cache makes processing them linear as well.

Before the next stage 1 opens, I plan to rework the GORI computations to be
more efficient on calculating outgoing ranges.

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

* [Bug tree-optimization/97359] [11 Regression] ice in logical_combine, at gimple-range-gori.cc:754
  2020-10-09 20:43 [Bug c/97359] New: ice in logical_combine, at gimple-range-gori.cc:754 dcb314 at hotmail dot com
                   ` (6 preceding siblings ...)
  2020-10-14 15:03 ` amacleod at redhat dot com
@ 2020-11-30  3:11 ` hjl.tools at gmail dot com
  7 siblings, 0 replies; 9+ messages in thread
From: hjl.tools at gmail dot com @ 2020-11-30  3:11 UTC (permalink / raw)
  To: gcc-bugs

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

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |haoxintu at gmail dot com

--- Comment #8 from H.J. Lu <hjl.tools at gmail dot com> ---
*** Bug 98051 has been marked as a duplicate of this bug. ***

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

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

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-09 20:43 [Bug c/97359] New: ice in logical_combine, at gimple-range-gori.cc:754 dcb314 at hotmail dot com
2020-10-09 20:47 ` [Bug c/97359] " dcb314 at hotmail dot com
2020-10-09 20:54 ` dcb314 at hotmail dot com
2020-10-09 21:34 ` [Bug tree-optimization/97359] [11 Regression] " jakub at gcc dot gnu.org
2020-10-10  6:50 ` aldyh at gcc dot gnu.org
2020-10-10  8:26 ` cvs-commit at gcc dot gnu.org
2020-10-10  8:28 ` aldyh at gcc dot gnu.org
2020-10-14 15:03 ` amacleod at redhat dot com
2020-11-30  3:11 ` hjl.tools at gmail 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).