Bootstrap and regtest running on x86_64-unknown-linux-gnu.

Richard.

2016-06-13  Richard Biener  <rguent...@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.

Index: gcc/tree-vrp.c
===================================================================
*** gcc/tree-vrp.c      (revision 237372)
--- gcc/tree-vrp.c      (working copy)
*************** extract_range_from_binary_expr_1 (value_
*** 2938,2944 ****
                     and divisor are available.  */
                  if (vr1.type == VR_RANGE
                      && !symbolic_range_p (&vr0)
!                     && !symbolic_range_p (&vr1))
                    min = int_const_binop (code, vr0.min, vr1.max);
                  else
                    min = zero;
--- 2944,2951 ----
                     and divisor are available.  */
                  if (vr1.type == VR_RANGE
                      && !symbolic_range_p (&vr0)
!                     && !symbolic_range_p (&vr1)
!                     && compare_values (vr1.max, zero) != 0)
                    min = int_const_binop (code, vr0.min, vr1.max);
                  else
                    min = zero;
Index: gcc/testsuite/gcc.dg/tree-ssa/vrp101.c
===================================================================
*** gcc/testsuite/gcc.dg/tree-ssa/vrp101.c      (revision 0)
--- gcc/testsuite/gcc.dg/tree-ssa/vrp101.c      (working copy)
***************
*** 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" } } */

Reply via email to