public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/109115] New: ICE on valid code at -O2 and -O3 on x86_64-linux-gnu: in upper_bound, at value-range.h:950
@ 2023-03-13 20:19 zhendong.su at inf dot ethz.ch
  2023-03-13 20:23 ` [Bug tree-optimization/109115] [13 Regression] " pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: zhendong.su at inf dot ethz.ch @ 2023-03-13 20:19 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109115
           Summary: ICE on valid code at -O2 and -O3 on x86_64-linux-gnu:
                    in upper_bound, at value-range.h:950
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It appears to be a recent regression as it does not reproduce with 12.2. 

Compiler Explorer: https://godbolt.org/z/Yjaj5qMvv

[569] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/13.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
--with-system-zlib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 13.0.1 20230313 (experimental) [master r13-6641-g23532dac3f6] (GCC)
[570] %
[570] % gcctk -Os small.c; ./a.out
[571] %
[571] % gcctk -O2 small.c
during GIMPLE pass: slp
small.c: In function ‘main’:
small.c:2:5: internal compiler error: in upper_bound, at value-range.h:950
    2 | int main() {
      |     ^~~~
0xc48c63 irange::upper_bound() const
        ../../gcc-trunk/gcc/value-range.h:950
0xc48c63 irange::upper_bound() const
        ../../gcc-trunk/gcc/value-range.h:947
0x1e9e7ca vect_recog_divmod_pattern
        ../../gcc-trunk/gcc/tree-vect-patterns.cc:3978
0x1e9808a vect_pattern_recog_1
        ../../gcc-trunk/gcc/tree-vect-patterns.cc:6244
0x1e9d3c1 vect_pattern_recog(vec_info*)
        ../../gcc-trunk/gcc/tree-vect-patterns.cc:6401
0x11a97dc vect_slp_analyze_bb_1
        ../../gcc-trunk/gcc/tree-vect-slp.cc:7310
0x11a97dc vect_slp_region
        ../../gcc-trunk/gcc/tree-vect-slp.cc:7419
0x11abac3 vect_slp_bbs
        ../../gcc-trunk/gcc/tree-vect-slp.cc:7610
0x11abe9c vect_slp_function(function*)
        ../../gcc-trunk/gcc/tree-vect-slp.cc:7698
0x11b6492 execute
        ../../gcc-trunk/gcc/tree-vectorizer.cc:1532
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.
[572] %
[572] % cat small.c
int a, b;
int main() {
  unsigned short c = a, e = -1;
  if (b) {
    unsigned d = (a ^ 1U) / a & c;
    int f = (~d >> ~a) / e;
    if (a)
      f = a;
    a = f;
  }
  return 0;
}

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

* [Bug tree-optimization/109115] [13 Regression] ICE on valid code at -O2 and -O3 on x86_64-linux-gnu: in upper_bound, at value-range.h:950
  2023-03-13 20:19 [Bug tree-optimization/109115] New: ICE on valid code at -O2 and -O3 on x86_64-linux-gnu: in upper_bound, at value-range.h:950 zhendong.su at inf dot ethz.ch
@ 2023-03-13 20:23 ` pinskia at gcc dot gnu.org
  2023-03-13 20:33 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-03-13 20:23 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|ICE on valid code at -O2    |[13 Regression] ICE on
                   |and -O3 on                  |valid code at -O2 and -O3
                   |x86_64-linux-gnu: in        |on x86_64-linux-gnu: in
                   |upper_bound, at             |upper_bound, at
                   |value-range.h:950           |value-range.h:950
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |ice-on-valid-code
   Target Milestone|---                         |13.0
   Last reconfirmed|                            |2023-03-13
     Ever confirmed|0                           |1

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Most likely introduced by r13-6619-g81fd62d1378b7d .

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

* [Bug tree-optimization/109115] [13 Regression] ICE on valid code at -O2 and -O3 on x86_64-linux-gnu: in upper_bound, at value-range.h:950
  2023-03-13 20:19 [Bug tree-optimization/109115] New: ICE on valid code at -O2 and -O3 on x86_64-linux-gnu: in upper_bound, at value-range.h:950 zhendong.su at inf dot ethz.ch
  2023-03-13 20:23 ` [Bug tree-optimization/109115] [13 Regression] " pinskia at gcc dot gnu.org
@ 2023-03-13 20:33 ` pinskia at gcc dot gnu.org
  2023-03-13 21:55 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-03-13 20:33 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|unknown                     |13.0

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I would have assumed range_of_expr would return false if r had no range
information ...


          if (ranger.range_of_expr (r, oprnd0, stmt))
            {
              wide_int max = r.upper_bound ();


Maybe there needs to be a check to make sure r.kind () is VR_RANGE then ...

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

* [Bug tree-optimization/109115] [13 Regression] ICE on valid code at -O2 and -O3 on x86_64-linux-gnu: in upper_bound, at value-range.h:950
  2023-03-13 20:19 [Bug tree-optimization/109115] New: ICE on valid code at -O2 and -O3 on x86_64-linux-gnu: in upper_bound, at value-range.h:950 zhendong.su at inf dot ethz.ch
  2023-03-13 20:23 ` [Bug tree-optimization/109115] [13 Regression] " pinskia at gcc dot gnu.org
  2023-03-13 20:33 ` pinskia at gcc dot gnu.org
@ 2023-03-13 21:55 ` jakub at gcc dot gnu.org
  2023-03-13 22:00 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-03-13 21:55 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I think it returns false if it is has a type which isn't representable with the
particular range.
Which isn't the case here.
The type is representable, just the range is undefined_p ().

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

* [Bug tree-optimization/109115] [13 Regression] ICE on valid code at -O2 and -O3 on x86_64-linux-gnu: in upper_bound, at value-range.h:950
  2023-03-13 20:19 [Bug tree-optimization/109115] New: ICE on valid code at -O2 and -O3 on x86_64-linux-gnu: in upper_bound, at value-range.h:950 zhendong.su at inf dot ethz.ch
                   ` (2 preceding siblings ...)
  2023-03-13 21:55 ` jakub at gcc dot gnu.org
@ 2023-03-13 22:00 ` jakub at gcc dot gnu.org
  2023-03-13 23:51 ` amacleod at redhat dot com
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-03-13 22:00 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |jakub at gcc dot gnu.org

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 54656
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54656&action=edit
gcc13-pr109115.patch

Untested fix.

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

* [Bug tree-optimization/109115] [13 Regression] ICE on valid code at -O2 and -O3 on x86_64-linux-gnu: in upper_bound, at value-range.h:950
  2023-03-13 20:19 [Bug tree-optimization/109115] New: ICE on valid code at -O2 and -O3 on x86_64-linux-gnu: in upper_bound, at value-range.h:950 zhendong.su at inf dot ethz.ch
                   ` (3 preceding siblings ...)
  2023-03-13 22:00 ` jakub at gcc dot gnu.org
@ 2023-03-13 23:51 ` amacleod at redhat dot com
  2023-03-14  8:16 ` cvs-commit at gcc dot gnu.org
  2023-03-14  8:17 ` jakub at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: amacleod at redhat dot com @ 2023-03-13 23:51 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Macleod <amacleod at redhat dot com> changed:

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

--- Comment #5 from Andrew Macleod <amacleod at redhat dot com> ---
(In reply to Jakub Jelinek from comment #3)
> I think it returns false if it is has a type which isn't representable with
> the particular range.
> Which isn't the case here.
> The type is representable, just the range is undefined_p ().

Correct. If the range is undefined, then you cannot ask for the upper bounds
because there is not one.

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

* [Bug tree-optimization/109115] [13 Regression] ICE on valid code at -O2 and -O3 on x86_64-linux-gnu: in upper_bound, at value-range.h:950
  2023-03-13 20:19 [Bug tree-optimization/109115] New: ICE on valid code at -O2 and -O3 on x86_64-linux-gnu: in upper_bound, at value-range.h:950 zhendong.su at inf dot ethz.ch
                   ` (4 preceding siblings ...)
  2023-03-13 23:51 ` amacleod at redhat dot com
@ 2023-03-14  8:16 ` cvs-commit at gcc dot gnu.org
  2023-03-14  8:17 ` jakub at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-03-14  8:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:72b52751c60abb327c73716259485d04b8eabe4f

commit r13-6653-g72b52751c60abb327c73716259485d04b8eabe4f
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Mar 14 09:15:38 2023 +0100

    tree-vect-patterns: Fix up ICE in upper_bound [PR109115]

    As mentioned in the PR, range_of_expr returns false if the type
    of the expression isn't suitable for corresponding range type,
    but doesn't if the range is undefined for other reasons.  Still,
    lower/upper_bound is defined only for ranges which actually have
    at least one pair of subranges, VR_UNDEFINED range doesn't have it.

    2023-03-14  Jakub Jelinek  <jakub@redhat.com>

            PR tree-optimization/109115
            * tree-vect-patterns.cc (vect_recog_divmod_pattern): Don't use
            r.upper_bound () on r.undefined_p () range.

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

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

* [Bug tree-optimization/109115] [13 Regression] ICE on valid code at -O2 and -O3 on x86_64-linux-gnu: in upper_bound, at value-range.h:950
  2023-03-13 20:19 [Bug tree-optimization/109115] New: ICE on valid code at -O2 and -O3 on x86_64-linux-gnu: in upper_bound, at value-range.h:950 zhendong.su at inf dot ethz.ch
                   ` (5 preceding siblings ...)
  2023-03-14  8:16 ` cvs-commit at gcc dot gnu.org
@ 2023-03-14  8:17 ` jakub at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-03-14  8:17 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED
           Priority|P3                          |P1

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2023-03-14  8:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-13 20:19 [Bug tree-optimization/109115] New: ICE on valid code at -O2 and -O3 on x86_64-linux-gnu: in upper_bound, at value-range.h:950 zhendong.su at inf dot ethz.ch
2023-03-13 20:23 ` [Bug tree-optimization/109115] [13 Regression] " pinskia at gcc dot gnu.org
2023-03-13 20:33 ` pinskia at gcc dot gnu.org
2023-03-13 21:55 ` jakub at gcc dot gnu.org
2023-03-13 22:00 ` jakub at gcc dot gnu.org
2023-03-13 23:51 ` amacleod at redhat dot com
2023-03-14  8:16 ` cvs-commit at gcc dot gnu.org
2023-03-14  8:17 ` jakub 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).