2018-10-22 Richard Biener <rguenther@suse.de>
authorRichard Biener <rguenth@gcc.gnu.org>
Mon, 22 Oct 2018 13:57:47 +0000 (13:57 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 22 Oct 2018 13:57:47 +0000 (13:57 +0000)
* gimple-ssa-evrp-analyze.c
(evrp_range_analyzer::record_ranges_from_incoming_edge): Be
smarter about what ranges to use.
* tree-vrp.c (add_assert_info): Dump here.
(register_edge_assert_for_2): Instead of here at multiple but
not all places.

* gcc.dg/tree-ssa/evrp12.c: New testcase.
* gcc.dg/predict-6.c: Adjust.
* gcc.dg/tree-ssa/vrp33.c: Disable EVRP.
* gcc.dg/tree-ssa/vrp02.c: Likewise.
* gcc.dg/tree-ssa/cunroll-9.c: Likewise.

From-SVN: r265391

gcc/ChangeLog
gcc/gimple-ssa-evrp-analyze.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/predict-6.c
gcc/testsuite/gcc.dg/tree-ssa/cunroll-9.c
gcc/testsuite/gcc.dg/tree-ssa/evrp12.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/vrp02.c
gcc/testsuite/gcc.dg/tree-ssa/vrp33.c
gcc/tree-vrp.c

index 54f36a1278df73739cdd4ffc16d819ae2d8010b2..96f187500df8dfd7cdfefcd38dd991f74706d486 100644 (file)
@@ -1,3 +1,18 @@
+2018-10-22  Richard Biener  <rguenther@suse.de>
+
+       * gimple-ssa-evrp-analyze.c
+       (evrp_range_analyzer::record_ranges_from_incoming_edge): Be
+       smarter about what ranges to use.
+       * tree-vrp.c (add_assert_info): Dump here.
+       (register_edge_assert_for_2): Instead of here at multiple but
+       not all places.
+
+       * gcc.dg/tree-ssa/evrp12.c: New testcase.
+       * gcc.dg/predict-6.c: Adjust.
+       * gcc.dg/tree-ssa/vrp33.c: Disable EVRP.
+       * gcc.dg/tree-ssa/vrp02.c: Likewise.
+       * gcc.dg/tree-ssa/cunroll-9.c: Likewise.
+
 2018-10-22  Steven Bosscher <steven@gcc.gnu.org>
        Richard Biener  <rguenther@suse.de>
 
index 83917f5eb0ad91a91f91b07f2d83646eef72b6e0..b7b0fd8f17c1741caf881feed65222d8fba656fc 100644 (file)
@@ -203,6 +203,16 @@ evrp_range_analyzer::record_ranges_from_incoming_edge (basic_block bb)
             ordering issues that can lead to worse ranges.  */
          for (unsigned i = 0; i < vrs.length (); ++i)
            {
+             /* But make sure we do not weaken ranges like when
+                getting first [64, +INF] and then ~[0, 0] from
+                conditions like (s & 0x3cc0) == 0).  */
+             value_range *old_vr = get_value_range (vrs[i].first);
+             value_range tem (old_vr->kind (), old_vr->min (), old_vr->max ());
+             tem.intersect (vrs[i].second);
+             if (tem.kind () == old_vr->kind ()
+                 && tem.min () == old_vr->min ()
+                 && tem.max () == old_vr->max ())
+               continue;
              push_value_range (vrs[i].first, vrs[i].second);
              if (is_fallthru
                  && all_uses_feed_or_dominated_by_stmt (vrs[i].first, stmt))
index b803f72cc9b94bd64db722c2c5b26bf4b9db155e..629f777279331bb3ab6b73ffb404aecad0ad2ce7 100644 (file)
@@ -1,6 +1,14 @@
+2018-10-22  Richard Biener  <rguenther@suse.de>
+
+       * gcc.dg/tree-ssa/evrp12.c: New testcase.
+       * gcc.dg/predict-6.c: Adjust.
+       * gcc.dg/tree-ssa/vrp33.c: Disable EVRP.
+       * gcc.dg/tree-ssa/vrp02.c: Likewise.
+       * gcc.dg/tree-ssa/cunroll-9.c: Likewise.
+
 2018-10-22  Martin Liska  <mliska@suse.cz>
 
-  PR tree-optimization/87686
+       PR tree-optimization/87686
        * g++.dg/tree-ssa/pr87686.C: New test.
 
 2018-10-22  Jakub Jelinek  <jakub@redhat.com>
index 5d6fbf158f298c927704c74de8e98c418006f2ba..08ce5cdb81d3d466839a2300f84815baf9936609 100644 (file)
@@ -10,9 +10,9 @@ void foo (int base, int bound)
   int i, ret = 0;
   for (i = base; i <= bound; i++)
     {
-      if (i < base)
+      if (i <= base)
        global += bar (i);
-      if (i < base + 1)
+      if (i < base + 2)
        global += bar (i);
       if (i <= base + 3)
        global += bar (i);
index 0e4407dcbd75b2dfce978b76edf38049f5285310..886dc147ad1a955c63bc1a0a560bb833e4181191 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-cunrolli-details" } */
+/* { dg-options "-O2 -fdump-tree-cunrolli-details -fdisable-tree-evrp" } */
 void abort (void);
 int q (void);
 int a[10];
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/evrp12.c b/gcc/testsuite/gcc.dg/tree-ssa/evrp12.c
new file mode 100644 (file)
index 0000000..b3906c2
--- /dev/null
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-evrp" } */
+
+extern void link_error ();
+
+void
+f3 (unsigned int s)
+{
+  if ((s & 0x3cc0) == 0)
+    {
+      if (s >= -15552U)
+       link_error ();
+    }
+  else
+    {
+      if (s <= 0x3f)
+       link_error ();
+    }
+}
+
+/* { dg-final { scan-tree-dump-not "link_error" "evrp" } } */
index 8d14feadb6aa0498a5ed5d568cda7750a6099047..4be538f5944ee5834fe8c043d042a2f187e0f07b 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-vrp1 -fdelete-null-pointer-checks" } */
+/* { dg-options "-O2 -fdump-tree-vrp1 -fdelete-null-pointer-checks -fdisable-tree-evrp" } */
 
 struct A
 {
index 75fefa49925d463a28f07ff1f2863b5c77865252..f1d3863943e4e78dfa3e803ef8d3d21cd4b959de 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-vrp1 -fno-tree-fre" } */
+/* { dg-options "-O2 -fdump-tree-vrp1 -fno-tree-fre -fdisable-tree-evrp" } */
 
 /* This is from PR14052.  */
 
index 28b4d566a526c3032f3f96c2d7d9261b1047e205..e3a64fd7e9e5d4a748dd1f8dd9d9cf7dbe1c57cf 100644 (file)
@@ -2299,6 +2299,9 @@ add_assert_info (vec<assert_info> &asserts,
   info.val = val;
   info.expr = expr;
   asserts.safe_push (info);
+  dump_printf (MSG_NOTE | MSG_PRIORITY_INTERNALS,
+              "Adding assert for %T from %T %s %T\n",
+              name, expr, op_symbol_code (comp_code), val);
 }
 
 /* If NAME doesn't have an ASSERT_EXPR registered for asserting
@@ -2698,16 +2701,6 @@ register_edge_assert_for_2 (tree name, edge e,
          tmp = build1 (NOP_EXPR, TREE_TYPE (name), name3);
          if (cst2 != NULL_TREE)
            tmp = build2 (PLUS_EXPR, TREE_TYPE (name), tmp, cst2);
-
-         if (dump_file)
-           {
-             fprintf (dump_file, "Adding assert for ");
-             print_generic_expr (dump_file, name3);
-             fprintf (dump_file, " from ");
-             print_generic_expr (dump_file, tmp);
-             fprintf (dump_file, "\n");
-           }
-
          add_assert_info (asserts, name3, tmp, comp_code, val);
        }
 
@@ -2725,16 +2718,6 @@ register_edge_assert_for_2 (tree name, edge e,
            tmp = build1 (NOP_EXPR, TREE_TYPE (name), tmp);
          if (cst2 != NULL_TREE)
            tmp = build2 (PLUS_EXPR, TREE_TYPE (name), tmp, cst2);
-
-         if (dump_file)
-           {
-             fprintf (dump_file, "Adding assert for ");
-             print_generic_expr (dump_file, name2);
-             fprintf (dump_file, " from ");
-             print_generic_expr (dump_file, tmp);
-             fprintf (dump_file, "\n");
-           }
-
          add_assert_info (asserts, name2, tmp, comp_code, val);
        }
     }
@@ -2857,16 +2840,6 @@ register_edge_assert_for_2 (tree name, edge e,
                  cst = fold_build2 (MINUS_EXPR, TREE_TYPE (name2), cst,
                                     build_int_cst (TREE_TYPE (name2), 1));
                }
-
-             if (dump_file)
-               {
-                 fprintf (dump_file, "Adding assert for ");
-                 print_generic_expr (dump_file, name2);
-                 fprintf (dump_file, " from ");
-                 print_generic_expr (dump_file, tmp);
-                 fprintf (dump_file, "\n");
-               }
-
              add_assert_info (asserts, name2, tmp, new_comp_code, cst);
            }
        }
@@ -2931,18 +2904,7 @@ register_edge_assert_for_2 (tree name, edge e,
            }
 
          if (new_val)
-           {
-             if (dump_file)
-               {
-                 fprintf (dump_file, "Adding assert for ");
-                 print_generic_expr (dump_file, name2);
-                 fprintf (dump_file, " from ");
-                 print_generic_expr (dump_file, tmp);
-                 fprintf (dump_file, "\n");
-               }
-
-             add_assert_info (asserts, name2, tmp, new_comp_code, new_val);
-           }
+           add_assert_info (asserts, name2, tmp, new_comp_code, new_val);
        }
 
       /* Add asserts for NAME cmp CST and NAME being defined as
@@ -3170,16 +3132,6 @@ register_edge_assert_for_2 (tree name, edge e,
                        maxv2 = maxv - minv;
                      }
                    new_val = wide_int_to_tree (type, maxv2);
-
-                   if (dump_file)
-                     {
-                       fprintf (dump_file, "Adding assert for ");
-                       print_generic_expr (dump_file, names[i]);
-                       fprintf (dump_file, " from ");
-                       print_generic_expr (dump_file, tmp);
-                       fprintf (dump_file, "\n");
-                     }
-
                    add_assert_info (asserts, names[i], tmp, LE_EXPR, new_val);
                  }
            }