Bug 98272 - [11 Regression] ICE: during GIMPLE pass: switchlower: in decompose, at wide-int.h:984 with -O -fno-tree-forwprop by r11-5836
Summary: [11 Regression] ICE: during GIMPLE pass: switchlower: in decompose, at wide-i...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 11.0
: P3 normal
Target Milestone: 11.0
Assignee: Eric Botcazou
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2020-12-14 12:17 UTC by Zdenek Sojka
Modified: 2020-12-16 08:43 UTC (History)
3 users (show)

See Also:
Host: x86_64-pc-linux-gnu
Target:
Build:
Known to work:
Known to fail: 11.0
Last reconfirmed: 2020-12-14 00:00:00


Attachments
reduced testcase (111 bytes, text/plain)
2020-12-14 12:17 UTC, Zdenek Sojka
Details
Tentative fix (480 bytes, patch)
2020-12-14 16:48 UTC, Eric Botcazou
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Zdenek Sojka 2020-12-14 12:17:36 UTC
Created attachment 49758 [details]
reduced testcase

Compiler output:
$ x86_64-pc-linux-gnu-gcc -O -fno-tree-forwprop testcase.c 
during GIMPLE pass: switchlower
testcase.c: In function 'foo':
testcase.c:4:1: internal compiler error: in decompose, at wide-int.h:984
    4 | foo (unsigned char uc)
      | ^~~
0x61a4c0 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&)
        /repo/gcc-trunk/gcc/wide-int.h:984
0xac2400 wi::int_traits<generic_wide_int<wide_int_storage> >::decompose(long*, unsigned int, generic_wide_int<wide_int_storage> const&)
        /repo/gcc-trunk/gcc/wide-int.h:1933
0xac2400 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)
        /repo/gcc-trunk/gcc/wide-int.h:1034
0xac2400 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)
        /repo/gcc-trunk/gcc/wide-int.h:790
0xac2400 bool wi::ltu_p<generic_wide_int<wide_int_storage>, generic_wide_int<wide_int_storage> >(generic_wide_int<wide_int_storage> const&, generic_wide_int<wide_int_storage> const&)
        /repo/gcc-trunk/gcc/wide-int.h:1937
0x10aa543 bool wi::lt_p<generic_wide_int<wide_int_storage>, generic_wide_int<wide_int_storage> >(generic_wide_int<wide_int_storage> const&, generic_wide_int<wide_int_storage> const&, signop)
        /repo/gcc-trunk/gcc/wide-int.h:1963
0x10aa543 tree_switch_conversion::bit_test_cluster::emit(tree_node*, tree_node*, tree_node*, basic_block_def*)
        /repo/gcc-trunk/gcc/tree-switch-conversion.c:1562
0x10aac3b tree_switch_conversion::switch_decision_tree::try_switch_expansion(vec<tree_switch_conversion::cluster*, va_heap, vl_ptr>&)
        /repo/gcc-trunk/gcc/tree-switch-conversion.c:1893
0x10ab413 tree_switch_conversion::switch_decision_tree::analyze_switch_statement()
        /repo/gcc-trunk/gcc/tree-switch-conversion.c:1823
0x10ac217 execute
        /repo/gcc-trunk/gcc/tree-switch-conversion.c:2570
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

$ x86_64-pc-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=/repo/gcc-trunk/binary-latest-amd64/bin/x86_64-pc-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/repo/gcc-trunk/binary-trunk-r11-5984-20201214092247-gcf7efe2d36f-checking-yes-rtl-df-extra-amd64/bin/../libexec/gcc/x86_64-pc-linux-gnu/11.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /repo/gcc-trunk//configure --enable-languages=c,c++ --enable-valgrind-annotations --disable-nls --enable-checking=yes,rtl,df,extra --with-cloog --with-ppl --with-isl --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --target=x86_64-pc-linux-gnu --with-ld=/usr/bin/x86_64-pc-linux-gnu-ld --with-as=/usr/bin/x86_64-pc-linux-gnu-as --disable-libstdcxx-pch --prefix=/repo/gcc-trunk//binary-trunk-r11-5984-20201214092247-gcf7efe2d36f-checking-yes-rtl-df-extra-amd64
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.0.0 20201214 (experimental) (GCC)
Comment 1 Martin Liška 2020-12-14 16:34:37 UTC
I can fix it.
Comment 2 Eric Botcazou 2020-12-14 16:48:37 UTC
Created attachment 49762 [details]
Tentative fix
Comment 3 GCC Commits 2020-12-16 08:43:15 UTC
The master branch has been updated by Eric Botcazou <ebotcazou@gcc.gnu.org>:

https://gcc.gnu.org/g:61e3c180ad6913fa5af39059de5ba7b3bde50cda

commit r11-6110-g61e3c180ad6913fa5af39059de5ba7b3bde50cda
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Wed Dec 16 09:39:07 2020 +0100

    Fix PR tree-optimization/98272
    
    This fixes the precision mismatch introduced by the previous change.
    
    gcc/ChangeLog:
            PR tree-optimization/98272
            * tree-switch-conversion.c (bit_test_cluster::emit): When finding
            out whether the entry test can be merged in the bit test, do the
            computation using the type of the index expression.
    
    gcc/testsuite/ChangeLog:
            * gcc.dg/pr98272.c: New test.
Comment 4 Eric Botcazou 2020-12-16 08:43:49 UTC
.