public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107732] New: ICE in lower_bound, at value-range.h:350
@ 2022-11-17  8:36 gcc-bugzilla at al42and dot me
  2022-11-17 15:12 ` [Bug c++/107732] " aldyh at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: gcc-bugzilla at al42and dot me @ 2022-11-17  8:36 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107732
           Summary: ICE in lower_bound, at value-range.h:350
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gcc-bugzilla at al42and dot me
  Target Milestone: ---

Created attachment 53916
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53916&action=edit
Preprocessed source (-freport-bug)

The following code (reduced example) triggers an ICE with a recent `master`
(96e4244ef3ccf4867ca4e37fbc6800e64ef30af6).

$ cat test.ii 
extern "C" double sqrt(double);
double a, b, c;
void d() {
  for (;;) {
    c = __builtin_fabs(a);
    sqrt(c);
    if (a)
      a = b;
  }
}

$ /home/aland/gcc-trunk/bin/g++ -O2 -c test.ii
during GIMPLE pass: thread
test.ii: In function ‘void d()’:
test.ii:3:6: internal compiler error: in lower_bound, at value-range.h:350
    3 | void d() {
      |      ^
0x9a92fc frange::lower_bound() const
        ../.././gcc/value-range.h:350
0x9a947d frange::lower_bound() const
        ../.././gcc/value-range.h:1127
0x9a947d foperator_abs::op1_range(frange&, tree_node*, frange const&, frange
const&, relation_trio) const
        ../.././gcc/range-op-float.cc:1413
0x211bc78 foperator_abs::op1_range(frange&, tree_node*, frange const&, frange
const&, relation_trio) const
        ../.././gcc/range-op-float.cc:1390
0x2002c25 gori_compute::compute_operand1_range(vrange&,
gimple_range_op_handler&, vrange const&, tree_node*, fur_source&,
value_relation*)
        ../.././gcc/gimple-range-gori.cc:1095
0x2001913 gori_compute::compute_operand_range(vrange&, gimple*, vrange const&,
tree_node*, fur_source&, value_relation*)
        ../.././gcc/gimple-range-gori.cc:692
0x2002c9f gori_compute::compute_operand1_range(vrange&,
gimple_range_op_handler&, vrange const&, tree_node*, fur_source&,
value_relation*)
        ../.././gcc/gimple-range-gori.cc:1150
0x2001913 gori_compute::compute_operand_range(vrange&, gimple*, vrange const&,
tree_node*, fur_source&, value_relation*)
        ../.././gcc/gimple-range-gori.cc:692
0x2005742 gori_compute::outgoing_edge_range_p(vrange&, edge_def*, tree_node*,
range_query&)
        ../.././gcc/gimple-range-gori.cc:1373
0x13d21fd path_range_query::compute_ranges_in_block(basic_block_def*)
        ../.././gcc/gimple-range-path.cc:454
0x13d28a2 path_range_query::compute_ranges(bitmap_head const*)
        ../.././gcc/gimple-range-path.cc:622
0x14569e9 back_threader::find_taken_edge_cond(vec<basic_block_def*, va_heap,
vl_ptr> const&, gcond*)
        ../.././gcc/tree-ssa-threadbackward.cc:324
0x1456b9e back_threader::maybe_register_path(back_threader_profitability&)
        ../.././gcc/tree-ssa-threadbackward.cc:248
0x1456ec8 back_threader::find_paths_to_names(basic_block_def*, bitmap_head*,
unsigned int, back_threader_profitability&)
        ../.././gcc/tree-ssa-threadbackward.cc:371
0x145737c back_threader::find_paths_to_names(basic_block_def*, bitmap_head*,
unsigned int, back_threader_profitability&)
        ../.././gcc/tree-ssa-threadbackward.cc:479
0x145737c back_threader::find_paths_to_names(basic_block_def*, bitmap_head*,
unsigned int, back_threader_profitability&)
        ../.././gcc/tree-ssa-threadbackward.cc:479
0x1457dbf back_threader::maybe_thread_block(basic_block_def*)
        ../.././gcc/tree-ssa-threadbackward.cc:551
0x1457e71 back_threader::thread_blocks()
        ../.././gcc/tree-ssa-threadbackward.cc:979
0x1457ed0 execute
        ../.././gcc/tree-ssa-threadbackward.cc:1081
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
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 c++/107732] ICE in lower_bound, at value-range.h:350
  2022-11-17  8:36 [Bug c++/107732] New: ICE in lower_bound, at value-range.h:350 gcc-bugzilla at al42and dot me
@ 2022-11-17 15:12 ` aldyh at gcc dot gnu.org
  2022-11-17 15:54 ` aldyh at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: aldyh at gcc dot gnu.org @ 2022-11-17 15:12 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-11-17
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
                 CC|                            |aldyh at gcc dot gnu.org

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

* [Bug c++/107732] ICE in lower_bound, at value-range.h:350
  2022-11-17  8:36 [Bug c++/107732] New: ICE in lower_bound, at value-range.h:350 gcc-bugzilla at al42and dot me
  2022-11-17 15:12 ` [Bug c++/107732] " aldyh at gcc dot gnu.org
@ 2022-11-17 15:54 ` aldyh at gcc dot gnu.org
  2022-11-17 16:24 ` gcc-bugzilla at al42and dot me
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: aldyh at gcc dot gnu.org @ 2022-11-17 15:54 UTC (permalink / raw)
  To: gcc-bugs

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

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

[PR tree-optimization/107732] [range-ops] Handle attempt to abs() negatives.

The threader is creating a scenario where we are trying to solve:

        [NEGATIVES] = abs(x)

While solving this we have an intermediate value of UNDEFINED because
we have no positive numbers.  But then we try to union the negative
pair to the final result by querying the bounds.  Since neither
UNDEFINED nor NAN have bounds, they need to be specially handled.

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

* [Bug c++/107732] ICE in lower_bound, at value-range.h:350
  2022-11-17  8:36 [Bug c++/107732] New: ICE in lower_bound, at value-range.h:350 gcc-bugzilla at al42and dot me
  2022-11-17 15:12 ` [Bug c++/107732] " aldyh at gcc dot gnu.org
  2022-11-17 15:54 ` aldyh at gcc dot gnu.org
@ 2022-11-17 16:24 ` gcc-bugzilla at al42and dot me
  2022-11-17 16:25 ` aldyh at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: gcc-bugzilla at al42and dot me @ 2022-11-17 16:24 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrey Alekseenko <gcc-bugzilla at al42and dot me> ---
@Aldy Hernandez, thank you. Can confirm that your patch fully resolves the
issue for me.

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

* [Bug c++/107732] ICE in lower_bound, at value-range.h:350
  2022-11-17  8:36 [Bug c++/107732] New: ICE in lower_bound, at value-range.h:350 gcc-bugzilla at al42and dot me
                   ` (2 preceding siblings ...)
  2022-11-17 16:24 ` gcc-bugzilla at al42and dot me
@ 2022-11-17 16:25 ` aldyh at gcc dot gnu.org
  2022-11-17 17:43 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: aldyh at gcc dot gnu.org @ 2022-11-17 16:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Aldy Hernandez <aldyh at gcc dot gnu.org> ---
(In reply to Andrey Alekseenko from comment #2)
> @Aldy Hernandez, thank you. Can confirm that your patch fully resolves the
> issue for me.

No problem.  Thank your for reporting and for reducing.  It makes my life
easier.

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

* [Bug c++/107732] ICE in lower_bound, at value-range.h:350
  2022-11-17  8:36 [Bug c++/107732] New: ICE in lower_bound, at value-range.h:350 gcc-bugzilla at al42and dot me
                   ` (3 preceding siblings ...)
  2022-11-17 16:25 ` aldyh at gcc dot gnu.org
@ 2022-11-17 17:43 ` cvs-commit at gcc dot gnu.org
  2022-11-17 17:45 ` aldyh at gcc dot gnu.org
  2022-11-28 22:25 ` [Bug c++/107732] [13 Regreession] " pinskia at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-11-17 17:43 UTC (permalink / raw)
  To: gcc-bugs

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

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

commit r13-4131-g4e306222f442f8d4c6fc6da997ab756a5e43e36e
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Thu Nov 17 16:47:17 2022 +0100

    [PR tree-optimization/107732] [range-ops] Handle attempt to abs()
negatives.

    The threader is creating a scenario where we are trying to solve:

            [NEGATIVES] = abs(x)

    While solving this we have an intermediate value of UNDEFINED because
    we have no positive numbers.  But then we try to union the negative
    pair to the final result by querying the bounds.  Since neither
    UNDEFINED nor NAN have bounds, they need to be specially handled.

            PR tree-optimization/107732

    gcc/ChangeLog:

            * range-op-float.cc (foperator_abs::op1_range): Early exit when
            result is undefined.

    gcc/testsuite/ChangeLog:

            * gcc.dg/tree-ssa/pr107732.c: New test.

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

* [Bug c++/107732] ICE in lower_bound, at value-range.h:350
  2022-11-17  8:36 [Bug c++/107732] New: ICE in lower_bound, at value-range.h:350 gcc-bugzilla at al42and dot me
                   ` (4 preceding siblings ...)
  2022-11-17 17:43 ` cvs-commit at gcc dot gnu.org
@ 2022-11-17 17:45 ` aldyh at gcc dot gnu.org
  2022-11-28 22:25 ` [Bug c++/107732] [13 Regreession] " pinskia at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: aldyh at gcc dot gnu.org @ 2022-11-17 17:45 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

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

* [Bug c++/107732] [13 Regreession] ICE in lower_bound, at value-range.h:350
  2022-11-17  8:36 [Bug c++/107732] New: ICE in lower_bound, at value-range.h:350 gcc-bugzilla at al42and dot me
                   ` (5 preceding siblings ...)
  2022-11-17 17:45 ` aldyh at gcc dot gnu.org
@ 2022-11-28 22:25 ` pinskia at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-28 22:25 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-valid-code
            Summary|ICE in lower_bound, at      |[13 Regreession] ICE in
                   |value-range.h:350           |lower_bound, at
                   |                            |value-range.h:350
   Target Milestone|---                         |13.0

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

end of thread, other threads:[~2022-11-28 22:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-17  8:36 [Bug c++/107732] New: ICE in lower_bound, at value-range.h:350 gcc-bugzilla at al42and dot me
2022-11-17 15:12 ` [Bug c++/107732] " aldyh at gcc dot gnu.org
2022-11-17 15:54 ` aldyh at gcc dot gnu.org
2022-11-17 16:24 ` gcc-bugzilla at al42and dot me
2022-11-17 16:25 ` aldyh at gcc dot gnu.org
2022-11-17 17:43 ` cvs-commit at gcc dot gnu.org
2022-11-17 17:45 ` aldyh at gcc dot gnu.org
2022-11-28 22:25 ` [Bug c++/107732] [13 Regreession] " pinskia 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).