]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/68671 (gcc.dg/torture/pr66952.c FAILs with -fno-tree-dce)
authorJakub Jelinek <jakub@redhat.com>
Fri, 4 Dec 2015 16:23:27 +0000 (17:23 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 4 Dec 2015 16:23:27 +0000 (17:23 +0100)
PR tree-optimization/68671
* tree-ssa-reassoc.c (maybe_optimize_range_tests): For basic
blocks starting with the successor of first bb we've modified
and ending with last_bb call reset_flow_sensitive_info_in_bb.

* gcc.dg/pr68671.c: New test.

From-SVN: r231278

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr68671.c [new file with mode: 0644]
gcc/tree-ssa-reassoc.c

index a3bde22653e77452a919612482b2b96bff62fe89..446e74b34682ec0b6c69860a4aafa878e7c2700c 100644 (file)
@@ -1,3 +1,10 @@
+2015-12-04  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/68671
+       * tree-ssa-reassoc.c (maybe_optimize_range_tests): For basic
+       blocks starting with the successor of first bb we've modified
+       and ending with last_bb call reset_flow_sensitive_info_in_bb.
+
 2015-12-04  Jeff Law  <law@redhat.com>
 
        * tree-ssa-reassoc.c (maybe_optimize_range_tests): Return boolean
index 4b1b1a3cee33d2ade6bd342adb18ea806d6b1999..1a037e6c1dcfbf50366a86b01938b86373d057ec 100644 (file)
@@ -1,3 +1,8 @@
+2015-12-04  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/68671
+       * gcc.dg/pr68671.c: New test.
+
 2015-12-02  Jeff Law  <law@redhat.com>
 
        * gcc.dg/tree-ssa/reassoc-43.c: New test.
diff --git a/gcc/testsuite/gcc.dg/pr68671.c b/gcc/testsuite/gcc.dg/pr68671.c
new file mode 100644 (file)
index 0000000..bec4639
--- /dev/null
@@ -0,0 +1,23 @@
+/* PR tree-optimization/68671 */
+/* { dg-do run } */
+/* { dg-options " -O2 -fno-tree-dce" } */
+
+volatile int a = -1;
+volatile int b;
+
+static inline int
+fn1 (signed char p1, int p2)
+{
+  return (p1 < 0) || (p1 > (1 >> p2)) ? 0 : (p1 << 1);
+}
+
+int
+main ()
+{
+  signed char c = a;
+  b = fn1 (c, 1);
+  c = ((128 | c) < 0 ? 1 : 0);
+  if (c != 1)
+    __builtin_abort ();
+  return 0;
+}
index 315b0bfc7ffd928fd5f74d3f881eeec486dcb587..e54700e2271e1829e03a5e94bd931fb87a23bbba 100644 (file)
@@ -3211,7 +3211,7 @@ maybe_optimize_range_tests (gimple *stmt)
     any_changes = optimize_range_tests (ERROR_MARK, &ops);
   if (any_changes)
     {
-      unsigned int idx;
+      unsigned int idx, max_idx = 0;
       /* update_ops relies on has_single_use predicates returning the
         same values as it did during get_ops earlier.  Additionally it
         never removes statements, only adds new ones and it should walk
@@ -3227,6 +3227,7 @@ maybe_optimize_range_tests (gimple *stmt)
            {
              tree new_op;
 
+             max_idx = idx;
              stmt = last_stmt (bb);
              new_op = update_ops (bbinfo[idx].op,
                                   (enum tree_code)
@@ -3296,6 +3297,10 @@ maybe_optimize_range_tests (gimple *stmt)
              && ops[bbinfo[idx].first_idx]->op != NULL_TREE)
            {
              gcond *cond_stmt = as_a <gcond *> (last_stmt (bb));
+
+             if (idx > max_idx)
+               max_idx = idx;
+
              /* If we collapse the conditional to a true/false
                 condition, then bubble that knowledge up to our caller.  */
              if (integer_zerop (ops[bbinfo[idx].first_idx]->op))
@@ -3320,6 +3325,17 @@ maybe_optimize_range_tests (gimple *stmt)
          if (bb == first_bb)
            break;
        }
+
+      /* The above changes could result in basic blocks after the first
+        modified one, up to and including last_bb, to be executed even if
+        they would not be in the original program.  If the value ranges of
+        assignment lhs' in those bbs were dependent on the conditions
+        guarding those basic blocks which now can change, the VRs might
+        be incorrect.  As no_side_effect_bb should ensure those SSA_NAMEs
+        are only used within the same bb, it should be not a big deal if
+        we just reset all the VRs in those bbs.  See PR68671.  */
+      for (bb = last_bb, idx = 0; idx < max_idx; bb = single_pred (bb), idx++)
+       reset_flow_sensitive_info_in_bb (bb);
     }
   return cfg_cleanup_needed;
 }