public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/111482] New: ice in lower_bound with -O3
@ 2023-09-19 15:26 dcb314 at hotmail dot com
  2023-09-19 16:01 ` [Bug c++/111482] [14 Regression] " mpolacek at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: dcb314 at hotmail dot com @ 2023-09-19 15:26 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111482
           Summary: ice in lower_bound with -O3
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dcb314 at hotmail dot com
  Target Milestone: ---

Created attachment 55934
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55934&action=edit
gzipped C++ source code

Given the attached C++ code and compiler flag -O3, recent gcc does
this:

during GIMPLE pass: vrp
bicgstab.cpp: In member function ‘QuantLib::BiCGStabResult
QuantLib::BiCGstab::solve(const QuantLib::Array&, const QuantLib::Array&)
const’:
bicgstab.cpp:37:20: internal compiler error: in lower_bound, at
value-range.h:1078
0xd452bb irange::lower_bound(unsigned int) const
        ../../trunk.year/gcc/value-range.h:1078
0x1800346 gimple_simplify_EXACT_DIV_EXPR(gimple_match_op*, gimple**, tree_node*
(*)(tree_node*), code_helper, tree_node*, tree_node*, tree_node*)
        /home/dcb38/gcc/working/gcc/gimple-match-9.cc:8878

git range seems to be g:a335cf241b93ae9e .. g:fe0f9e0941304748,
a range of 48 commits.

I have a reduction running, but since this is C++, I am not expecting
fast results.

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

* [Bug c++/111482] [14 Regression] ice in lower_bound with -O3
  2023-09-19 15:26 [Bug c++/111482] New: ice in lower_bound with -O3 dcb314 at hotmail dot com
@ 2023-09-19 16:01 ` mpolacek at gcc dot gnu.org
  2023-09-19 16:06 ` mpolacek at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-09-19 16:01 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Target Milestone|---                         |14.0
                 CC|                            |mpolacek at gcc dot gnu.org
            Summary|ice in lower_bound with -O3 |[14 Regression] ice in
                   |                            |lower_bound with -O3
           Keywords|                            |ice-on-valid-code
   Last reconfirmed|                            |2023-09-19
           Priority|P3                          |P1
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed.

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

* [Bug c++/111482] [14 Regression] ice in lower_bound with -O3
  2023-09-19 15:26 [Bug c++/111482] New: ice in lower_bound with -O3 dcb314 at hotmail dot com
  2023-09-19 16:01 ` [Bug c++/111482] [14 Regression] " mpolacek at gcc dot gnu.org
@ 2023-09-19 16:06 ` mpolacek at gcc dot gnu.org
  2023-09-19 16:15 ` zhendong.su at inf dot ethz.ch
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-09-19 16:06 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |guojiufu at gcc dot gnu.org
           Keywords|                            |needs-reduction

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Started with r14-3644:

commit 1aceceb1e2d6e86ce183c8cc448750fa03b6f79e
Author: Jiufu Guo <guojiufu@linux.ibm.com>
Date:   Mon Sep 4 10:31:04 2023 +0800

    Optimize '(X - N * M) / N' to 'X / N - M' if valid

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

* [Bug c++/111482] [14 Regression] ice in lower_bound with -O3
  2023-09-19 15:26 [Bug c++/111482] New: ice in lower_bound with -O3 dcb314 at hotmail dot com
  2023-09-19 16:01 ` [Bug c++/111482] [14 Regression] " mpolacek at gcc dot gnu.org
  2023-09-19 16:06 ` mpolacek at gcc dot gnu.org
@ 2023-09-19 16:15 ` zhendong.su at inf dot ethz.ch
  2023-09-19 16:33 ` dcb314 at hotmail dot com
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: zhendong.su at inf dot ethz.ch @ 2023-09-19 16:15 UTC (permalink / raw)
  To: gcc-bugs

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

Zhendong Su <zhendong.su at inf dot ethz.ch> changed:

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

--- Comment #3 from Zhendong Su <zhendong.su at inf dot ethz.ch> ---
See also https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111355

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

* [Bug c++/111482] [14 Regression] ice in lower_bound with -O3
  2023-09-19 15:26 [Bug c++/111482] New: ice in lower_bound with -O3 dcb314 at hotmail dot com
                   ` (2 preceding siblings ...)
  2023-09-19 16:15 ` zhendong.su at inf dot ethz.ch
@ 2023-09-19 16:33 ` dcb314 at hotmail dot com
  2023-09-20  2:54 ` guojiufu at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: dcb314 at hotmail dot com @ 2023-09-19 16:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from David Binderman <dcb314 at hotmail dot com> ---
Created attachment 55937
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55937&action=edit
partially reduced C++ source code

After an hour of reduction, I have the attached C++ file.

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

* [Bug c++/111482] [14 Regression] ice in lower_bound with -O3
  2023-09-19 15:26 [Bug c++/111482] New: ice in lower_bound with -O3 dcb314 at hotmail dot com
                   ` (3 preceding siblings ...)
  2023-09-19 16:33 ` dcb314 at hotmail dot com
@ 2023-09-20  2:54 ` guojiufu at gcc dot gnu.org
  2023-09-20  3:29 ` guojiufu at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: guojiufu at gcc dot gnu.org @ 2023-09-20  2:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jiu Fu Guo <guojiufu at gcc dot gnu.org> ---
Thanks a lot for reporting this!

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

* [Bug c++/111482] [14 Regression] ice in lower_bound with -O3
  2023-09-19 15:26 [Bug c++/111482] New: ice in lower_bound with -O3 dcb314 at hotmail dot com
                   ` (4 preceding siblings ...)
  2023-09-20  2:54 ` guojiufu at gcc dot gnu.org
@ 2023-09-20  3:29 ` guojiufu at gcc dot gnu.org
  2023-09-20  4:10 ` guojiufu at gcc dot gnu.org
  2023-09-21  7:33 ` [Bug tree-optimization/111482] " guojiufu at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: guojiufu at gcc dot gnu.org @ 2023-09-20  3:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Jiu Fu Guo <guojiufu at gcc dot gnu.org> ---
I reproduced these issue PR11148 and PR111355 on ppc64le too.

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

* [Bug c++/111482] [14 Regression] ice in lower_bound with -O3
  2023-09-19 15:26 [Bug c++/111482] New: ice in lower_bound with -O3 dcb314 at hotmail dot com
                   ` (5 preceding siblings ...)
  2023-09-20  3:29 ` guojiufu at gcc dot gnu.org
@ 2023-09-20  4:10 ` guojiufu at gcc dot gnu.org
  2023-09-21  7:33 ` [Bug tree-optimization/111482] " guojiufu at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: guojiufu at gcc dot gnu.org @ 2023-09-20  4:10 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Jiu Fu Guo <guojiufu at gcc dot gnu.org> ---
This is caused by missing to check a vr's "undefine_p".

In the pattern "(X + C) / N", 

    (if (exact_mod (c)
...
          && range_op_handler (PLUS_EXPR).overflow_free_p (vr0, vr1) 
...)
       (plus (op @0 @2) { wide_int_to_tree (type, plus_op1 (c)); })
       (if (TYPE_UNSIGNED (type) && c.sign_mask () < 0
            && exact_mod (-c)
            /* unsigned "X-(-C)" doesn't underflow.  */
            && wi::geu_p (vr0.lower_bound (), -c))

In the "(if (exact_mode (c)" part, the code "overflow_free_p (vr0, vr1)" checks
v0/vr are defined. 
But in the "else" part, "if (... && wi::geu_p (vr0.lower_bound (), -c)", vr0 is
not checked undefined_p.

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

* [Bug tree-optimization/111482] [14 Regression] ice in lower_bound with -O3
  2023-09-19 15:26 [Bug c++/111482] New: ice in lower_bound with -O3 dcb314 at hotmail dot com
                   ` (6 preceding siblings ...)
  2023-09-20  4:10 ` guojiufu at gcc dot gnu.org
@ 2023-09-21  7:33 ` guojiufu at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: guojiufu at gcc dot gnu.org @ 2023-09-21  7:33 UTC (permalink / raw)
  To: gcc-bugs

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

Jiu Fu Guo <guojiufu at gcc dot gnu.org> changed:

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

--- Comment #8 from Jiu Fu Guo <guojiufu at gcc dot gnu.org> ---
Fix via r14-4192-g4d80863d7f93c0a839d1fe5dc59be83153e89110.

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

end of thread, other threads:[~2023-09-21  7:33 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-19 15:26 [Bug c++/111482] New: ice in lower_bound with -O3 dcb314 at hotmail dot com
2023-09-19 16:01 ` [Bug c++/111482] [14 Regression] " mpolacek at gcc dot gnu.org
2023-09-19 16:06 ` mpolacek at gcc dot gnu.org
2023-09-19 16:15 ` zhendong.su at inf dot ethz.ch
2023-09-19 16:33 ` dcb314 at hotmail dot com
2023-09-20  2:54 ` guojiufu at gcc dot gnu.org
2023-09-20  3:29 ` guojiufu at gcc dot gnu.org
2023-09-20  4:10 ` guojiufu at gcc dot gnu.org
2023-09-21  7:33 ` [Bug tree-optimization/111482] " guojiufu 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).