From 4a7bfd79b39b751f7fd864c4e65c478dea9d3dd2 Mon Sep 17 00:00:00 2001 From: Aldy Hernandez Date: Mon, 27 Apr 2020 14:18:35 +0200 Subject: Fix union_ so it works with signed 1-bit numbers. --- gcc/range-op.cc | 12 ++++++++++++ gcc/value-range.cc | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'gcc') diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 9d8bc6e..85fb187 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -3375,6 +3375,18 @@ range_tests () int_range<1> i1, i2, i3; int_range<1> r0, r1, rold; + // Test 1-bit signed integer union. + // [-1,-1] U [0,0] = VARYING. + tree one_bit_type = build_nonstandard_integer_type (1, 0); + { + tree one_bit_min = vrp_val_min (one_bit_type); + tree one_bit_max = vrp_val_max (one_bit_type); + int_range<2> min (one_bit_min, one_bit_min); + int_range<2> max (one_bit_max, one_bit_max); + max.union_ (min); + ASSERT_TRUE (max.varying_p ()); + } + // Test that NOT(255) is [0..254] in 8-bit land. int_range<1> not_255 (UCHAR (255), UCHAR (255), VR_ANTI_RANGE); ASSERT_TRUE (not_255 == int_range<1> (UCHAR (0), UCHAR (254))); diff --git a/gcc/value-range.cc b/gcc/value-range.cc index cc260f1..379792d 100644 --- a/gcc/value-range.cc +++ b/gcc/value-range.cc @@ -1878,7 +1878,7 @@ irange::multi_range_union (const irange &r) // Overflow indicates we are at MAX already. // A wide int bug requires the previous max_val check // trigger: gcc.c-torture/compile/pr80443.c with -O3 - if (ovf) + if (ovf == wi::OVF_OVERFLOW) break; // Current upper+1 is >= lower bound next pair, then we merge ranges. -- cgit v1.1