@@ -3837,6 +3837,27 @@ range_tests ()
r0.invert ();
ASSERT_TRUE (r0.nonzero_p ());
+ // test legacy interaction
+ // r0 = ~[1,1]
+ r0 = int_range<1> (UINT (1), UINT (1), VR_ANTI_RANGE);
+ // r1 = ~[3,3]
+ r1 = int_range<1> (UINT (3), UINT (3), VR_ANTI_RANGE);
+
+ // vv = [0,0][2,2][4, MAX]
+ int_range<3> vv = r0;
+ vv.intersect (r1);
+
+ ASSERT_TRUE (vv.contains_p (UINT (2)));
+ ASSERT_TRUE (vv.num_pairs () == 3);
+
+ // create r0 as legacy [1,1]
+ r0 = int_range<1> (UINT (1), UINT (1));
+ // And union it with [0,0][2,2][4,MAX] multi range
+ r0.union_ (vv);
+ // The result should be [0,2][4,MAX], or ~[3,3] but it must contain 2
+ ASSERT_TRUE (r0.contains_p (UINT (2)));
+
+
multi_precision_range_tests ();
int_range_max_tests ();
operator_tests ();
@@ -1093,19 +1093,14 @@ intersect_ranges (enum value_range_kind *vr0type,
void
irange::legacy_intersect (irange *vr0, const irange *vr1)
{
+ gcc_checking_assert (vr0->legacy_mode_p ());
+ gcc_checking_assert (vr1->legacy_mode_p ());
/* If either range is VR_VARYING the other one wins. */
if (vr1->varying_p ())
return;
if (vr0->varying_p ())
{
- /* Avoid the full copy if we already know both sides are simple
- and can be trivially copied. */
- if (vr1->legacy_mode_p ())
- {
- vr0->set (vr1->min (), vr1->max (), vr1->kind ());
- return;
- }
- *vr0 = *vr1;
+ vr0->set (vr1->min (), vr1->max (), vr1->kind ());
return;
}
@@ -1122,17 +1117,9 @@ irange::legacy_intersect (irange *vr0, const
irange *vr1)
value_range_kind vr0kind = vr0->kind ();
tree vr0min = vr0->min ();
tree vr0max = vr0->max ();
- /* Handle multi-ranges that can be represented as anti-ranges. */
- if (!vr1->legacy_mode_p () && vr1->maybe_anti_range ())
- {
- int_range<3> tmp (*vr1);
- tmp.invert ();
- intersect_ranges (&vr0kind, &vr0min, &vr0max,
- VR_ANTI_RANGE, tmp.min (), tmp.max ());
- }
- else
- intersect_ranges (&vr0kind, &vr0min, &vr0max,
- vr1->kind (), vr1->min (), vr1->max ());
+
+ intersect_ranges (&vr0kind, &vr0min, &vr0max,
+ vr1->kind (), vr1->min (), vr1->max ());
/* Make sure to canonicalize the result though as the inversion of a