This patch removes a buggy special case in irange::invert which seems
to have been broken for a while, and probably never triggered because
the legacy code was handled elsewhere, and the non-legacy code was
using an int_range_max of int_range<255> which made it extremely
likely for num_ranges == 255. However, with auto-resizing ranges,
int_range_max will start off at 3 and can hit this bogus code in the
unswitching code.
PR tree-optimization/109934
gcc/ChangeLog:
* value-range.cc (irange::invert): Remove buggy special case.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/pr109934.c: New test.
--- /dev/null
+// { dg-do run }
+// { dg-options "-O3" }
+
+int printf(const char *, ...);
+short a;
+long b = 3, c;
+int d(int e) {
+ switch (e)
+ case 111:
+ case 222:
+ case 44:
+ return 0;
+ return e;
+}
+int main() {
+ for (; a >= 0; --a)
+ if (d(c + 23) - 23)
+ b = 0;
+
+ if (b != 3)
+ __builtin_abort ();
+}
wide_int type_min = wi::min_value (prec, sign);
wide_int type_max = wi::max_value (prec, sign);
m_nonzero_mask = wi::minus_one (prec);
- if (m_num_ranges == m_max_ranges
- && lower_bound () != type_min
- && upper_bound () != type_max)
- {
- m_base[1] = type_max;
- m_num_ranges = 1;
- return;
- }
// At this point, we need one extra sub-range to represent the
// inverse.