2016-10-12 Richard Biener <rguenther@suse.de>
authorRichard Biener <rguenther@suse.de>
Wed, 12 Oct 2016 07:10:07 +0000 (07:10 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 12 Oct 2016 07:10:07 +0000 (07:10 +0000)
* tree-ssa-propagate.c
(substitute_and_fold_dom_walker::before_dom_children): Do not
ignore ASSERT_EXPRs but only preserve them.
* tree-vrp.c (remove_range_assertions): Deal with ASSERT_EXPRs
that have been propagated into.
(vrp_finalize): Enable DCE for substitute_and_fold.

* gcc.dg/tree-ssa/vrp35.c: Adjust.
* gcc.dg/tree-ssa/vrp36.c: Likewise.
* gcc.dg/tree-ssa/vrp46.c: Likewise.

From-SVN: r241021

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/vrp35.c
gcc/testsuite/gcc.dg/tree-ssa/vrp36.c
gcc/testsuite/gcc.dg/tree-ssa/vrp46.c
gcc/tree-ssa-propagate.c
gcc/tree-vrp.c

index 92a45d90cdc55657b85fe731809de3d97d25fdaf..30c186a9b27eb2aeb3ad196f6ed3e6a405a55c2e 100644 (file)
@@ -1,3 +1,12 @@
+2016-10-12  Richard Biener  <rguenther@suse.de>
+
+       * tree-ssa-propagate.c
+       (substitute_and_fold_dom_walker::before_dom_children): Do not
+       ignore ASSERT_EXPRs but only preserve them.
+       * tree-vrp.c (remove_range_assertions): Deal with ASSERT_EXPRs
+       that have been propagated into.
+       (vrp_finalize): Enable DCE for substitute_and_fold.
+
 2016-10-12  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/77920
index 1ebd9bd01d9654596aac4925e31852ca3d662c79..1c4d4cf8de2e5d29400e3ad1e3e21066ab362f8a 100644 (file)
@@ -1,3 +1,9 @@
+2016-10-12  Richard Biener  <rguenther@suse.de>
+
+       * gcc.dg/tree-ssa/vrp35.c: Adjust.
+       * gcc.dg/tree-ssa/vrp36.c: Likewise.
+       * gcc.dg/tree-ssa/vrp46.c: Likewise.
+
 2016-10-12  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/77920
index 1cf310bbffde25d63cd740c4c424ce105e873e30..20112eafd533b5445492bb093b990150e818a3a8 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-vrp1" } */
+/* { dg-options "-O2 -fdump-tree-vrp1-details" } */
 
 int test1(int i, int k)
 {
@@ -11,4 +11,4 @@ int test1(int i, int k)
   return 1;
 }
 
-/* { dg-final { scan-tree-dump "Folding predicate j_.* == 10 to 0" "vrp1" } } */
+/* { dg-final { scan-tree-dump "Removing dead stmt \[^\r\n\]* = j_.* == 10" "vrp1" } } */
index 873a7c9de913aaeb29c443cd1ebeb2aff7367c11..3933254474a66d2b4fef95cb5aa9392d6c944847 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-vrp1" } */
+/* { dg-options "-O2 -fdump-tree-vrp1-details" } */
 
 int foo(int i)
 {
@@ -8,4 +8,4 @@ int foo(int i)
   return 1;
 }
 
-/* { dg-final { scan-tree-dump "Folding predicate i_.* == 1 to 0" "vrp1" } } */
+/* { dg-final { scan-tree-dump "Removing dead stmt \[^\r\n\]* = i_.* == 1" "vrp1" } } */
index d3c9ed144f387cc98f549a5d0bf1b4ece89a81cb..ebdc2e3eedb17c5acc16f13714c8648728204034 100644 (file)
@@ -27,6 +27,6 @@ func_18 ( int t )
     }
 }
 
-/* There should be a single if left.  */
+/* There should be no if left.  */
 
-/* { dg-final { scan-tree-dump-times "if" 1 "vrp1" } } */
+/* { dg-final { scan-tree-dump-times "if" 0 "vrp1" } } */
index cd1cbd283252217232913e426792af7edc4eb5f4..0f940cc56b58b2435adcfe282fdb72d36db309f4 100644 (file)
@@ -1035,15 +1035,6 @@ substitute_and_fold_dom_walker::before_dom_children (basic_block bb)
     {
       bool did_replace;
       gimple *stmt = gsi_stmt (i);
-      enum gimple_code code = gimple_code (stmt);
-
-      /* Ignore ASSERT_EXPRs.  They are used by VRP to generate
-        range information for names and they are discarded
-        afterwards.  */
-
-      if (code == GIMPLE_ASSIGN
-         && TREE_CODE (gimple_assign_rhs1 (stmt)) == ASSERT_EXPR)
-       continue;
 
       /* No point propagating into a stmt we have a value for we
          can propagate into all uses.  Mark it for removal instead.  */
@@ -1056,7 +1047,10 @@ substitute_and_fold_dom_walker::before_dom_children (basic_block bb)
              && sprime != lhs
              && may_propagate_copy (lhs, sprime)
              && !stmt_could_throw_p (stmt)
-             && !gimple_has_side_effects (stmt))
+             && !gimple_has_side_effects (stmt)
+             /* We have to leave ASSERT_EXPRs around for jump-threading.  */
+             && (!is_gimple_assign (stmt)
+                 || gimple_assign_rhs_code (stmt) != ASSERT_EXPR))
            {
              stmts_to_remove.safe_push (stmt);
              continue;
index e46f7fcf085cc3caec9744c0e84be2e3b70c163b..8d5fa66e08459b2b7937b2fdf6b00f1a8f374ec0 100644 (file)
@@ -6894,9 +6894,9 @@ remove_range_assertions (void)
            imm_use_iterator iter;
 
            var = ASSERT_EXPR_VAR (rhs);
-           gcc_assert (TREE_CODE (var) == SSA_NAME);
 
-           if (!POINTER_TYPE_P (TREE_TYPE (lhs))
+           if (TREE_CODE (var) == SSA_NAME
+               && !POINTER_TYPE_P (TREE_TYPE (lhs))
                && SSA_NAME_RANGE_INFO (lhs))
              {
                if (is_unreachable == -1)
@@ -6928,8 +6928,11 @@ remove_range_assertions (void)
 
            /* Propagate the RHS into every use of the LHS.  */
            FOR_EACH_IMM_USE_STMT (use_stmt, iter, lhs)
-             FOR_EACH_IMM_USE_ON_STMT (use_p, iter)
-               SET_USE (use_p, var);
+             {
+               FOR_EACH_IMM_USE_ON_STMT (use_p, iter)
+                 SET_USE (use_p, var);
+               update_stmt (use_stmt);
+             }
 
            /* And finally, remove the copy, it is not needed.  */
            gsi_remove (&si, true);
@@ -10611,7 +10614,7 @@ vrp_finalize (bool warn_array_bounds_p)
       }
 
   substitute_and_fold (op_with_constant_singleton_value_range,
-                      vrp_fold_stmt, false);
+                      vrp_fold_stmt, true);
 
   if (warn_array_bounds && warn_array_bounds_p)
     check_all_array_refs ();