aboutsummaryrefslogtreecommitdiff
path: root/gcc/range-op.cc
diff options
context:
space:
mode:
authorAldy Hernandez <aldyh@redhat.com>2020-09-15 17:33:48 +0200
committerAldy Hernandez <aldyh@redhat.com>2020-09-17 12:51:54 +0200
commit80cbca32464ae05931c0ae425eec7d1f373946eb (patch)
tree2b70518f772436d94a175d5cc07cfafdd2ebf1c2 /gcc/range-op.cc
parent27eac88a3f23ef7efbbd725504963cffc71dcad4 (diff)
downloadgcc-80cbca32464ae05931c0ae425eec7d1f373946eb.zip
gcc-80cbca32464ae05931c0ae425eec7d1f373946eb.tar.gz
gcc-80cbca32464ae05931c0ae425eec7d1f373946eb.tar.bz2
Allow copying of symbolic ranges to an irange.
This fixes an ICE when trying to copy a legacy value_range containing a symbolic to a multi-range: min = make_ssa_name (type); max = build_int_cst (type, 55); value_range vv (min, max); int_range<2> vr = vv; gcc/ChangeLog: * range-op.cc (multi_precision_range_tests): Normalize symbolics when copying to a multi-range. * value-range.cc (irange::copy_legacy_range): Add test.
Diffstat (limited to 'gcc/range-op.cc')
-rw-r--r--gcc/range-op.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/gcc/range-op.cc b/gcc/range-op.cc
index fbf78be..3ab268f 100644
--- a/gcc/range-op.cc
+++ b/gcc/range-op.cc
@@ -3453,6 +3453,21 @@ multi_precision_range_tests ()
small = big;
ASSERT_TRUE (small == int_range<1> (INT (21), INT (21), VR_ANTI_RANGE));
+ // Copying a legacy symbolic to an int_range should normalize the
+ // symbolic at copy time.
+ {
+ tree ssa = make_ssa_name (integer_type_node);
+ value_range legacy_range (ssa, INT (25));
+ int_range<2> copy = legacy_range;
+ ASSERT_TRUE (copy == int_range<2> (vrp_val_min (integer_type_node),
+ INT (25)));
+
+ // Test that copying ~[abc_23, abc_23] to a multi-range yields varying.
+ legacy_range = value_range (ssa, ssa, VR_ANTI_RANGE);
+ copy = legacy_range;
+ ASSERT_TRUE (copy.varying_p ());
+ }
+
range3_tests ();
}