From: Richard Biener Date: Tue, 14 Jun 2016 07:22:04 +0000 (+0000) Subject: re PR tree-optimization/71521 (Regression in GCC-7.0.0's optimizer) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=90b72e84c427d4e735ae98dc06fe84fc1ec8139b;p=gcc.git re PR tree-optimization/71521 (Regression in GCC-7.0.0's optimizer) 2016-06-14 Richard Biener 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5c3375e550e..f0077b8d605 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-06-14 Richard Biener + + 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 * config/i386/i386.md (signbittf2): New expander. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 45862f3851c..8763aad7556 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2016-06-14 Richard Biener + + 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 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 index 00000000000..cfca5396e63 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp101.c @@ -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 ":\[\n\r \]*return 0;" "optimized" } } */ diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 68f2e905424..ecfab1f53ec 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -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;