public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/105770] New: [13 Regression] ICE in decompose, at wide-int.h:984
@ 2022-05-30  7:26 asolokha at gmx dot com
  2022-05-30  8:58 ` [Bug tree-optimization/105770] " jakub at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: asolokha at gmx dot com @ 2022-05-30  7:26 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105770
           Summary: [13 Regression] ICE in decompose, at wide-int.h:984
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: asolokha at gmx dot com
  Target Milestone: ---

gcc 13.0.0 20220529 snapshot (g:58a40e76ebadce78639644cd3d56e42b68336927) ICEs
when compiling the following testcase, reduced from
gcc/testsuite/gcc.dg/analyzer/pr103892.c, w/ -O1 -funswitch-loops
-fno-tree-forwprop:

char argstr;

void
argstr_get_word (void)
{
  while (argstr)
    switch (argstr)
      {
      case ' ':
      case '\t':
        return;
      }

  __builtin_unreachable ();
}

% gcc-13.0.0 -O1 -funswitch-loops -fno-tree-forwprop -c hlkdlkuv.c
during GIMPLE pass: unswitch
hlkdlkuv.c: In function 'argstr_get_word':
hlkdlkuv.c:4:1: internal compiler error: in decompose, at wide-int.h:984
    4 | argstr_get_word (void)
      | ^~~~~~~~~~~~~~~
0x7e7cea wi::int_traits<generic_wide_int<wide_int_ref_storage<false, false> >
>::decompose(long*, unsigned int, generic_wide_int<wide_int_ref_storage<false,
false> > const&)
       
/var/tmp/portage/sys-devel/gcc-13.0.0_p20220529/work/gcc-13-20220529/gcc/wide-int.h:984
0x7ec593 wi::int_traits<generic_wide_int<wide_int_storage> >::decompose(long*,
unsigned int, generic_wide_int<wide_int_storage> const&)
       
/var/tmp/portage/sys-devel/gcc-13.0.0_p20220529/work/gcc-13-20220529/gcc/tree.h:3701
0x7ec593 wide_int_ref_storage<true,
false>::wide_int_ref_storage<generic_wide_int<wide_int_storage>
>(generic_wide_int<wide_int_storage> const&, unsigned int)
       
/var/tmp/portage/sys-devel/gcc-13.0.0_p20220529/work/gcc-13-20220529/gcc/wide-int.h:1034
0x7ec593 generic_wide_int<wide_int_ref_storage<true, false>
>::generic_wide_int<generic_wide_int<wide_int_storage>
>(generic_wide_int<wide_int_storage> const&, unsigned int)
       
/var/tmp/portage/sys-devel/gcc-13.0.0_p20220529/work/gcc-13-20220529/gcc/wide-int.h:790
0x7ec593 wi::binary_traits<generic_wide_int<wide_int_ref_storage<false, false>
>, generic_wide_int<wide_int_storage>,
wi::int_traits<generic_wide_int<wide_int_ref_storage<false, false> >
>::precision_type, wi::int_traits<generic_wide_int<wide_int_storage>
>::precision_type>::result_type
wi::bit_and_not<generic_wide_int<wide_int_ref_storage<false, false> >,
generic_wide_int<wide_int_storage>
>(generic_wide_int<wide_int_ref_storage<false, false> > const&,
generic_wide_int<wide_int_storage> const&)
       
/var/tmp/portage/sys-devel/gcc-13.0.0_p20220529/work/gcc-13-20220529/gcc/wide-int.h:2343
0x7ec593 generic_simplify_111
       
/var/tmp/portage/sys-devel/gcc-13.0.0_p20220529/work/build/gcc/generic-match.cc:8192
0x169139f generic_simplify_EQ_EXPR
       
/var/tmp/portage/sys-devel/gcc-13.0.0_p20220529/work/build/gcc/generic-match.cc:56962
0xb44402 fold_binary_loc(unsigned int, tree_code, tree_node*, tree_node*,
tree_node*)
       
/var/tmp/portage/sys-devel/gcc-13.0.0_p20220529/work/gcc-13-20220529/gcc/fold-const.cc:10902
0xb4cdda fold_build2_loc(unsigned int, tree_code, tree_node*, tree_node*,
tree_node*)
       
/var/tmp/portage/sys-devel/gcc-13.0.0_p20220529/work/gcc-13-20220529/gcc/fold-const.cc:13854
0x1071bb3 find_unswitching_predicates_for_bb
       
/var/tmp/portage/sys-devel/gcc-13.0.0_p20220529/work/gcc-13-20220529/gcc/tree-ssa-loop-unswitch.cc:537
0x1075b19 init_loop_unswitch_info
       
/var/tmp/portage/sys-devel/gcc-13.0.0_p20220529/work/gcc-13-20220529/gcc/tree-ssa-loop-unswitch.cc:268
0x1075b19 tree_ssa_unswitch_loops(function*)
       
/var/tmp/portage/sys-devel/gcc-13.0.0_p20220529/work/gcc-13-20220529/gcc/tree-ssa-loop-unswitch.cc:332

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

* [Bug tree-optimization/105770] [13 Regression] ICE in decompose, at wide-int.h:984
  2022-05-30  7:26 [Bug tree-optimization/105770] New: [13 Regression] ICE in decompose, at wide-int.h:984 asolokha at gmx dot com
@ 2022-05-30  8:58 ` jakub at gcc dot gnu.org
  2022-05-30  9:02 ` [Bug tree-optimization/105770] [13 Regression] ICE in decompose, at wide-int.h:984 since r13-754 jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-05-30  8:58 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2022-05-30

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

* [Bug tree-optimization/105770] [13 Regression] ICE in decompose, at wide-int.h:984 since r13-754
  2022-05-30  7:26 [Bug tree-optimization/105770] New: [13 Regression] ICE in decompose, at wide-int.h:984 asolokha at gmx dot com
  2022-05-30  8:58 ` [Bug tree-optimization/105770] " jakub at gcc dot gnu.org
@ 2022-05-30  9:02 ` jakub at gcc dot gnu.org
  2022-05-30  9:11 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-05-30  9:02 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |13.0
            Summary|[13 Regression] ICE in      |[13 Regression] ICE in
                   |decompose, at               |decompose, at
                   |wide-int.h:984              |wide-int.h:984 since
                   |                            |r13-754
           Priority|P3                          |P1

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r13-754-ga1c9f779f75283427316b5c670c1e01ff8ce9ced
--- gcc/tree-ssa-loop-unswitch.cc.jj    2022-05-25 11:07:29.754185772 +0200
+++ gcc/tree-ssa-loop-unswitch.cc       2022-05-30 10:57:23.165131441 +0200
@@ -494,6 +494,7 @@ find_unswitching_predicates_for_bb (basi
     {
       unsigned nlabels = gimple_switch_num_labels (stmt);
       tree idx = gimple_switch_index (stmt);
+      tree idx_type = TREE_TYPE (idx);
       if (TREE_CODE (idx) != SSA_NAME
          || nlabels < 1)
        return;
@@ -526,16 +527,18 @@ find_unswitching_predicates_for_bb (basi
          if (CASE_HIGH (lab) != NULL_TREE)
            {
              tree cmp1 = fold_build2 (GE_EXPR, boolean_type_node, idx,
-                                      CASE_LOW (lab));
+                                      fold_convert (idx_type,
+                                                    CASE_LOW (lab)));
              tree cmp2 = fold_build2 (LE_EXPR, boolean_type_node, idx,
-                                      CASE_HIGH (lab));
+                                      fold_convert (idx_type,
+                                                    CASE_HIGH (lab)));
              cmp = fold_build2 (BIT_AND_EXPR, boolean_type_node, cmp1, cmp2);
              lab_range.set (CASE_LOW (lab), CASE_HIGH (lab));
            }
          else
            {
              cmp = fold_build2 (EQ_EXPR, boolean_type_node, idx,
-                                CASE_LOW (lab));
+                                fold_convert (idx_type, CASE_LOW (lab)));
              lab_range.set (CASE_LOW (lab));
            }

fixes it for me.

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

* [Bug tree-optimization/105770] [13 Regression] ICE in decompose, at wide-int.h:984 since r13-754
  2022-05-30  7:26 [Bug tree-optimization/105770] New: [13 Regression] ICE in decompose, at wide-int.h:984 asolokha at gmx dot com
  2022-05-30  8:58 ` [Bug tree-optimization/105770] " jakub at gcc dot gnu.org
  2022-05-30  9:02 ` [Bug tree-optimization/105770] [13 Regression] ICE in decompose, at wide-int.h:984 since r13-754 jakub at gcc dot gnu.org
@ 2022-05-30  9:11 ` jakub at gcc dot gnu.org
  2022-05-30  9:30 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-05-30  9:11 UTC (permalink / raw)
  To: gcc-bugs

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

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

Full untested patch.

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

* [Bug tree-optimization/105770] [13 Regression] ICE in decompose, at wide-int.h:984 since r13-754
  2022-05-30  7:26 [Bug tree-optimization/105770] New: [13 Regression] ICE in decompose, at wide-int.h:984 asolokha at gmx dot com
                   ` (2 preceding siblings ...)
  2022-05-30  9:11 ` jakub at gcc dot gnu.org
@ 2022-05-30  9:30 ` rguenth at gcc dot gnu.org
  2022-05-30  9:36 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-05-30  9:30 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
LGTM - IIRC at some point we required the case labels to have compatible types
to the index, didn't we?

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

* [Bug tree-optimization/105770] [13 Regression] ICE in decompose, at wide-int.h:984 since r13-754
  2022-05-30  7:26 [Bug tree-optimization/105770] New: [13 Regression] ICE in decompose, at wide-int.h:984 asolokha at gmx dot com
                   ` (3 preceding siblings ...)
  2022-05-30  9:30 ` rguenth at gcc dot gnu.org
@ 2022-05-30  9:36 ` jakub at gcc dot gnu.org
  2022-06-01 12:01 ` cvs-commit at gcc dot gnu.org
  2022-06-01 12:03 ` jakub at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-05-30  9:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I think all the case labels are required to have the same types, but the index
can be promoted (such as in this case promotion from char to int).  I've looked
at other switch handling cases and they do such conversions there.

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

* [Bug tree-optimization/105770] [13 Regression] ICE in decompose, at wide-int.h:984 since r13-754
  2022-05-30  7:26 [Bug tree-optimization/105770] New: [13 Regression] ICE in decompose, at wide-int.h:984 asolokha at gmx dot com
                   ` (4 preceding siblings ...)
  2022-05-30  9:36 ` jakub at gcc dot gnu.org
@ 2022-06-01 12:01 ` cvs-commit at gcc dot gnu.org
  2022-06-01 12:03 ` jakub at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-06-01 12:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 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:0d5cc976a36af07c9790c38a99a0b98110c89795

commit r13-912-g0d5cc976a36af07c9790c38a99a0b98110c89795
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Jun 1 14:00:49 2022 +0200

    unswitch: Fold case label lo/hi values to index type [PR105770]

    The following testcase ICEs because we use different types in comparison,
    idx has int type, while CASE_LOW has char type.

    While I believe all CASE_{LOW,HIGH} in the same switch have to use the same
    or compatible type, the index expression can have a promoted type as
happens
    in this testcase.  Other spots that handle switches do such foldings too.

    2022-06-01  Jakub Jelinek  <jakub@redhat.com>

            PR tree-optimization/105770
            * tree-ssa-loop-unswitch.cc (find_unswitching_predicates_for_bb):
Cast
            CASE_LOW and CASE_HIGH to TREE_TYPE (idx) before comparisons with
idx.

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

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

* [Bug tree-optimization/105770] [13 Regression] ICE in decompose, at wide-int.h:984 since r13-754
  2022-05-30  7:26 [Bug tree-optimization/105770] New: [13 Regression] ICE in decompose, at wide-int.h:984 asolokha at gmx dot com
                   ` (5 preceding siblings ...)
  2022-06-01 12:01 ` cvs-commit at gcc dot gnu.org
@ 2022-06-01 12:03 ` jakub at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-06-01 12:03 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

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

end of thread, other threads:[~2022-06-01 12:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-30  7:26 [Bug tree-optimization/105770] New: [13 Regression] ICE in decompose, at wide-int.h:984 asolokha at gmx dot com
2022-05-30  8:58 ` [Bug tree-optimization/105770] " jakub at gcc dot gnu.org
2022-05-30  9:02 ` [Bug tree-optimization/105770] [13 Regression] ICE in decompose, at wide-int.h:984 since r13-754 jakub at gcc dot gnu.org
2022-05-30  9:11 ` jakub at gcc dot gnu.org
2022-05-30  9:30 ` rguenth at gcc dot gnu.org
2022-05-30  9:36 ` jakub at gcc dot gnu.org
2022-06-01 12:01 ` cvs-commit at gcc dot gnu.org
2022-06-01 12:03 ` 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).