]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
2018-12-10 Richard Biener <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 10 Dec 2018 13:56:51 +0000 (13:56 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 10 Dec 2018 13:56:51 +0000 (13:56 +0000)
PR tree-optimization/88427
* vr-values.c (vr_values::extract_range_from_phi_node):
Handle symbolic ranges conservatively when trying to drop
to Inf +- 1.

* gcc.dg/pr88427.c: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@266955 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr88427.c [new file with mode: 0644]
gcc/vr-values.c

index 600cb4738c3e925eff2b8ed0ce108ce7c63a6785..e91b1f93e7e6aefd2ab75ac57d5998443985ee45 100644 (file)
@@ -1,3 +1,10 @@
+2018-12-10  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/88427
+       * vr-values.c (vr_values::extract_range_from_phi_node):
+       Handle symbolic ranges conservatively when trying to drop
+       to Inf +- 1.
+
 2018-12-10  Martin Jambor  <mjambor@suse.cz>
 
        PR ipa/88214
index fa7bb7b34f20fdf558884438365f6812faec0fcb..2d5b36614dc0ffb4273539d1da3ac06a099c750f 100644 (file)
@@ -1,3 +1,8 @@
+2018-12-10  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/88427
+       * gcc.dg/pr88427.c: New testcase.
+
 2018-12-10  Jakub Jelinek  <jakub@redhat.com>
 
        PR ipa/87955
diff --git a/gcc/testsuite/gcc.dg/pr88427.c b/gcc/testsuite/gcc.dg/pr88427.c
new file mode 100644 (file)
index 0000000..60b179c
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-tree-dce -fno-tree-fre -Wno-div-by-zero" } */
+
+void
+uj (int eq, int s4)
+{
+  short int tm = 0;
+
+  for (;;)
+    if (eq == s4)
+      {
+       tm += !!s4;
+       if (tm == s4)
+         {
+           eq += tm;
+           for (;;)
+             eq /= 0;
+         }
+      }
+}
index 075ea8431a6baa7de9c716f068713955b7e04ac6..cbc759a18e6af0843c8cc67975ab0ff37006a2f6 100644 (file)
@@ -2891,8 +2891,9 @@ vr_values::extract_range_from_phi_node (gphi *phi, value_range *vr_result)
       if (cmp_min < 0)
        new_min = lhs_vr->min ();
       else if (cmp_min > 0
-              && tree_int_cst_lt (vrp_val_min (vr_result->type ()),
-                                  vr_result->min ()))
+              && (TREE_CODE (vr_result->min ()) != INTEGER_CST
+                  || tree_int_cst_lt (vrp_val_min (vr_result->type ()),
+                                      vr_result->min ())))
        new_min = int_const_binop (PLUS_EXPR,
                                   vrp_val_min (vr_result->type ()),
                                   build_int_cst (vr_result->type (), 1));
@@ -2901,8 +2902,9 @@ vr_values::extract_range_from_phi_node (gphi *phi, value_range *vr_result)
       if (cmp_max > 0)
        new_max = lhs_vr->max ();
       else if (cmp_max < 0
-              && tree_int_cst_lt (vr_result->max (),
-                                  vrp_val_max (vr_result->type ())))
+              && (TREE_CODE (vr_result->max ()) != INTEGER_CST
+                  || tree_int_cst_lt (vr_result->max (),
+                                      vrp_val_max (vr_result->type ()))))
        new_max = int_const_binop (MINUS_EXPR,
                                   vrp_val_max (vr_result->type ()),
                                   build_int_cst (vr_result->type (), 1));