bounds_of_var_in_loop is returning an overflowed int, which is causing
us to create a range for which we can't compare the bounds causing
an ICE in verify_range.
Overflowed bounds cause compare_values() to return -2, which we
don't handle in verify_range.
We don't represent overflowed ranges in irange, so this patch just
saturates any overflowed end-points to MIN or MAX.
gcc/ChangeLog:
PR tree-optimization/97501
* gimple-range.cc (gimple_ranger::range_of_ssa_name_with_loop_info):
Saturate overflows returned from SCEV.
gcc/testsuite/ChangeLog:
* gcc.dg/pr97501.c: New test.
// ?? We could do better here. Since MIN/MAX can only be an
// SSA, SSA +- INTEGER_CST, or INTEGER_CST, we could easily call
// the ranger and solve anything not an integer.
- if (TREE_CODE (min) != INTEGER_CST)
+ if (TREE_CODE (min) != INTEGER_CST || TREE_OVERFLOW (min))
min = vrp_val_min (type);
- if (TREE_CODE (max) != INTEGER_CST)
+ if (TREE_CODE (max) != INTEGER_CST || TREE_OVERFLOW (max))
max = vrp_val_max (type);
r.set (min, max);
}
--- /dev/null
+// { dg-do compile }
+// { dg-options "-O2" }
+
+static int c = 0;
+
+int main() {
+ int b = 0;
+ if (c) {
+ for (;; b--)
+ do
+ b++;
+ while (b);
+ }
+}