re PR tree-optimization/71521 (Regression in GCC-7.0.0's optimizer)
authorRichard Biener <rguenther@suse.de>
Tue, 14 Jun 2016 07:22:04 +0000 (07:22 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 14 Jun 2016 07:22:04 +0000 (07:22 +0000)
2016-06-14  Richard Biener  <rguenther@suse.de>

PR tree-optimization/71521
* tree-vrp.c (extract_range_from_binary_expr_1): Guard
division int_const_binop against zero divisor.

* gcc.dg/tree-ssa/vrp101.c: New testcase.

From-SVN: r237425

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/vrp101.c [new file with mode: 0644]
gcc/tree-vrp.c

index 5c3375e550e11fa482fd51af76533ef808756a87..f0077b8d605e9821827bdc14a21200c26e7fb4b5 100644 (file)
@@ -1,3 +1,9 @@
+2016-06-14  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/71521
+       * tree-vrp.c (extract_range_from_binary_expr_1): Guard
+       division int_const_binop against zero divisor.
+
 2016-06-13  Uros Bizjak  <ubizjak@gmail.com>
 
        * config/i386/i386.md (signbittf2): New expander.
index 45862f3851cec23018fd14a1a6eaa5dc9472399b..8763aad7556b12edaa1710564d5cf6bd08f1b179 100644 (file)
@@ -1,3 +1,9 @@
+2016-06-14  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/71521
+       * tree-vrp.c (extract_range_from_binary_expr_1): Guard
+       division int_const_binop against zero divisor.
+
 2016-06-13  Jakub Jelinek  <jakub@redhat.com>
 
        PR sanitizer/71498
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp101.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp101.c
new file mode 100644 (file)
index 0000000..cfca539
--- /dev/null
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+int x = 1;
+
+int main ()
+{
+  int t = (1/(1>=x))>>1;
+  if (t != 0) __builtin_abort();
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump "<bb 2>:\[\n\r \]*return 0;" "optimized" } } */
index 68f2e905424999e2a639c02ae74b160ebfe8a067..ecfab1f53ecd8115af07b02063f22434157f558c 100644 (file)
@@ -2938,7 +2938,8 @@ extract_range_from_binary_expr_1 (value_range *vr,
                     and divisor are available.  */
                  if (vr1.type == VR_RANGE
                      && !symbolic_range_p (&vr0)
-                     && !symbolic_range_p (&vr1))
+                     && !symbolic_range_p (&vr1)
+                     && compare_values (vr1.max, zero) != 0)
                    min = int_const_binop (code, vr0.min, vr1.max);
                  else
                    min = zero;