aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAldy Hernandez <aldyh@redhat.com>2020-10-20 15:25:20 +0200
committerAldy Hernandez <aldyh@redhat.com>2020-10-20 17:23:12 +0200
commit5d53ec27015b916640171e891870adf2c6fdfd4c (patch)
treee40dddc65912a5f0727da9e19536a0c53948fea6
parentdbcc6b1577bedd2bf5879393c862b6c461787503 (diff)
downloadgcc-5d53ec27015b916640171e891870adf2c6fdfd4c.zip
gcc-5d53ec27015b916640171e891870adf2c6fdfd4c.tar.gz
gcc-5d53ec27015b916640171e891870adf2c6fdfd4c.tar.bz2
Saturate overflows return from SCEV in ranger.
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.
-rw-r--r--gcc/gimple-range.cc4
-rw-r--r--gcc/testsuite/gcc.dg/pr97501.c14
2 files changed, 16 insertions, 2 deletions
diff --git a/gcc/gimple-range.cc b/gcc/gimple-range.cc
index e4864ba..ed9609b 100644
--- a/gcc/gimple-range.cc
+++ b/gcc/gimple-range.cc
@@ -1146,9 +1146,9 @@ gimple_ranger::range_of_ssa_name_with_loop_info (irange &r, tree name,
// ?? 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);
}
diff --git a/gcc/testsuite/gcc.dg/pr97501.c b/gcc/testsuite/gcc.dg/pr97501.c
new file mode 100644
index 0000000..aedac83
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr97501.c
@@ -0,0 +1,14 @@
+// { dg-do compile }
+// { dg-options "-O2" }
+
+static int c = 0;
+
+int main() {
+ int b = 0;
+ if (c) {
+ for (;; b--)
+ do
+ b++;
+ while (b);
+ }
+}