aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAldy Hernandez <aldyh@redhat.com>2020-03-13 17:12:56 +0100
committerAldy Hernandez <aldyh@redhat.com>2020-03-13 13:28:07 -0400
commitc6a2bc2f87e14f81a979d8d648ce1a68a40e9833 (patch)
treed9a40fff0626b5069574b52610a508a305d84930 /gcc
parent2b00c489070afb0d4891d5ba41d8847aa2cb3db1 (diff)
downloadgcc-c6a2bc2f87e14f81a979d8d648ce1a68a40e9833.zip
gcc-c6a2bc2f87e14f81a979d8d648ce1a68a40e9833.tar.gz
gcc-c6a2bc2f87e14f81a979d8d648ce1a68a40e9833.tar.bz2
Fix infinite loop on truncating widest_irange copies.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/range-op.cc6
-rw-r--r--gcc/value-range.cc15
2 files changed, 11 insertions, 10 deletions
diff --git a/gcc/range-op.cc b/gcc/range-op.cc
index ca87e8e..2e19a3c 100644
--- a/gcc/range-op.cc
+++ b/gcc/range-op.cc
@@ -3332,11 +3332,15 @@ widest_irange_tests ()
static void
multi_precision_range_tests ()
{
- // Test truncating copy.
+ // Test truncating copy to int_range<1>.
int_range<3> big = build_range3 (10, 20, 30, 40, 50, 60);
int_range<1> small = big;
ASSERT_TRUE (small == int_range<1> (INT (10), INT (60)));
+ // Test truncating copy to int_range<2>.
+ int_range<2> medium = big;
+ ASSERT_TRUE (!medium.undefined_p ());
+
// Test that a truncating copy of [MIN,20][22,40][80,MAX]
// ends up as a conservative anti-range of ~[21,21].
big = int_range<3> (vrp_val_min (integer_type_node), INT (20));
diff --git a/gcc/value-range.cc b/gcc/value-range.cc
index b996708..4a4c487 100644
--- a/gcc/value-range.cc
+++ b/gcc/value-range.cc
@@ -1798,12 +1798,7 @@ irange::intersect (const vrange &vr)
void
irange::multi_range_union (const irange &r)
{
- if (undefined_p ())
- {
- *this = r;
- return;
- }
- else if (r.undefined_p ())
+ if (r.undefined_p ())
return;
// Do not worry about merging and such by reserving twice as many
@@ -1818,7 +1813,8 @@ irange::multi_range_union (const irange &r)
// the merge is performed.
//
// [Xi,Yi]..[Xn,Yn] U [Xj,Yj]..[Xm,Ym] --> [Xk,Yk]..[Xp,Yp]
- signop sign = TYPE_SIGN (type ());
+ tree ttype = r.type ();
+ signop sign = TYPE_SIGN (ttype);
// ?? We may need something faster than vectors here, not sure.
auto_vec<wide_int, 8> res;
wide_int u1 ;
@@ -1858,7 +1854,7 @@ irange::multi_range_union (const irange &r)
// Now normalize the vector removing any overlaps.
i = 2;
- int prec = TYPE_PRECISION (type ());
+ int prec = TYPE_PRECISION (ttype);
wide_int max_val = wi::max_value (prec, sign);
for (j = 2; j < k ; j += 2)
{
@@ -1905,8 +1901,9 @@ irange::multi_range_union (const irange &r)
}
for (j = 0; j < i ; j++)
- m_base[j] = wide_int_to_tree (type (), res [j]);
+ m_base[j] = wide_int_to_tree (ttype, res [j]);
m_num_ranges = i / 2;
+ m_kind = VR_RANGE;
if (flag_checking)
check ();