Bug 97767 - [11 Regression] ICE in extract_range_basic, at vr-values.c:1445 since r11-4532-g054d7b9f6f6816a8
Summary: [11 Regression] ICE in extract_range_basic, at vr-values.c:1445 since r11-453...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 11.0
: P1 normal
Target Milestone: 11.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2020-11-09 15:58 UTC by Arseny Solokha
Modified: 2020-11-10 08:31 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work: 10.2.0
Known to fail: 11.0
Last reconfirmed: 2020-11-09 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Arseny Solokha 2020-11-09 15:58:34 UTC
g++-11.0.0-alpha20201101 snapshot (g:590febb5f6624f78b36402a7c9a9c318978f1efa) ICEs when compiling gcc/testsuite/gcc.dg/builtins-66.c w/ -O1 -fstrict-enums -ftree-vrp:

% g++-11.0.0 -O1 -fstrict-enums -ftree-vrp -c gcc/testsuite/gcc.dg/builtins-66.c
during GIMPLE pass: evrp
gcc/testsuite/gcc.dg/builtins-66.c: In function 'int foo()':
gcc/testsuite/gcc.dg/builtins-66.c:9:1: internal compiler error: in extract_range_basic, at vr-values.c:1445
    9 | }
      | ^
0x7fa858 vr_values::extract_range_basic(value_range_equiv*, gimple*)
	/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20201101/work/gcc-11-20201101/gcc/vr-values.c:1445
0x19d1bf5 evrp_range_analyzer::record_ranges_from_stmt(gimple*, bool)
	/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20201101/work/gcc-11-20201101/gcc/gimple-ssa-evrp-analyze.c:304
0x11cd124 substitute_and_fold_dom_walker::before_dom_children(basic_block_def*)
	/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20201101/work/gcc-11-20201101/gcc/tree-ssa-propagate.c:1099
0x199be37 dom_walker::walk(basic_block_def*)
	/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20201101/work/gcc-11-20201101/gcc/domwalk.c:309
0x11cc1b7 substitute_and_fold_engine::substitute_and_fold(basic_block_def*)
	/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20201101/work/gcc-11-20201101/gcc/tree-ssa-propagate.c:1283
0x19cfabe execute_early_vrp
	/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20201101/work/gcc-11-20201101/gcc/gimple-ssa-evrp.c:349
Comment 1 Martin Liška 2020-11-09 16:40:11 UTC
Confirmed, started with r11-4532-g054d7b9f6f6816a8.
Comment 2 GCC Commits 2020-11-10 08:29:08 UTC
The master branch has been updated by Aldy Hernandez <aldyh@gcc.gnu.org>:

https://gcc.gnu.org/g:3d3470e239e8040f642a8852721b4962b4ed36f2

commit r11-4864-g3d3470e239e8040f642a8852721b4962b4ed36f2
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Mon Nov 9 20:35:25 2020 +0100

    Normalize VARYING for -fstrict-enums.
    
    The problem here is that the representation for VARYING in
    -fstrict-enums is different between value_range and irange.
    
    The helper function irange::normalize_min_max() will normalize to
    VARYING only if setting the range to the entire domain of the
    underlying type.  That is, [0, 0xff..ff], not the domain as defined by
    -fstrict-enums.  This causes problems because the multi-range version
    of varying_p() will return true if the range is the domain as defined
    by -fstrict-enums.  Thus, normalize_min_max and varying_p have
    different concepts of varying for multi-ranges.
    
    (BTW, legacy ranges are different because they never look at the
    extremes of a range to determine varying-ness.  They only look at the
    kind field.)
    
    One approach is to change all the code to limit ranges to the domain
    in the -fstrict-enums world, but this won't work because there are
    various instances of gimple where the values assigned or compared are
    beyond the limits of TYPE_{MIN,MAX}_VALUE.  One example is the
    addition of 0xffffffff to represent subtraction.
    
    This patch fixes multi-range varying_p() and set_varying() to agree
    with the normalization code, using the extremes of the underlying type,
    to represent varying.
    
    gcc/ChangeLog:
    
            PR tree-optimization/97767
            * value-range.cc (dump_bound_with_infinite_markers): Use
            wi::min_value and wi::max_value.
            (range_tests_strict_enum): New.
            (range_tests): Call range_tests_strict_enum.
            * value-range.h (irange::varying_p): Use wi::min_value
            and wi::max_value.
            (irange::set_varying): Same.
            (irange::normalize_min_max): Remove comment.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/opt/pr97767.C: New test.
Comment 3 Aldy Hernandez 2020-11-10 08:31:10 UTC
fixed