re PR tree-optimization/70724 (Miscompiles python3 with FDO)
authorRichard Biener <rguenther@suse.de>
Tue, 19 Apr 2016 13:22:19 +0000 (13:22 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 19 Apr 2016 13:22:19 +0000 (13:22 +0000)
2016-04-19  Richard Biener  <rguenther@suse.de>

PR tree-optimization/70724
* tree-ssa-sccvn.c (scc_vn_restore_ssa_info): Split SSA info
restoring out from ...
(free_scc_vn): ... here.
* tree-ssa-sccvn.h (scc_vn_restore_ssa_info): Declare.
* tres-ssa-pre.c (pass_pre::execute): Restore SSA info before
tail merging.
(pass_fre::execute): Restore SSA info.

* gcc.dg/torture/pr70724.c: New testcase.

From-SVN: r235203

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr70724.c [new file with mode: 0644]
gcc/tree-ssa-pre.c
gcc/tree-ssa-sccvn.c
gcc/tree-ssa-sccvn.h

index 39bbca2..6c338f7 100644 (file)
@@ -1,5 +1,16 @@
 2016-04-19  Richard Biener  <rguenther@suse.de>
 
+       PR tree-optimization/70724
+       * tree-ssa-sccvn.c (scc_vn_restore_ssa_info): Split SSA info
+       restoring out from ...
+       (free_scc_vn): ... here.
+       * tree-ssa-sccvn.h (scc_vn_restore_ssa_info): Declare.
+       * tres-ssa-pre.c (pass_pre::execute): Restore SSA info before
+       tail merging.
+       (pass_fre::execute): Restore SSA info.
+
+2016-04-19  Richard Biener  <rguenther@suse.de>
+
        * gimple-walk.h (struct walk_stmt_info): Add stmt member.
        * gimple-walk.c (walk_gimple_op): Initialize it.
        (walk_gimple_asm): Set wi->is_lhs before each callback invocation.
index e6bd406..da83d7e 100644 (file)
@@ -1,3 +1,8 @@
+2016-04-19  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/70724
+       * gcc.dg/torture/pr70724.c: New testcase.
+
 2016-04-18  Vladimir Makarov  <vmakarov@redhat.com>
 
        PR middle-end/70689
diff --git a/gcc/testsuite/gcc.dg/torture/pr70724.c b/gcc/testsuite/gcc.dg/torture/pr70724.c
new file mode 100644 (file)
index 0000000..d4cffb3
--- /dev/null
@@ -0,0 +1,39 @@
+/* { dg-do run } */
+/* { dg-additional-options "-ftracer" } */
+
+extern void abort (void);
+
+typedef long int _PyTime_t;
+typedef enum { _PyTime_ROUND_FLOOR = 0, _PyTime_ROUND_CEILING = 1 }
+  _PyTime_round_t;
+
+static _PyTime_t
+_PyTime_Divide(const _PyTime_t t, const _PyTime_t k,
+              const _PyTime_round_t round)
+{
+  if (round == _PyTime_ROUND_CEILING) {
+      if (t >= 0)
+       return (t + k - 1) / k;
+      else
+       return t / k;
+  }
+  else {
+      if (t >= 0)
+       return t / k;
+      else
+       return (t - (k - 1)) / k;
+  }
+}
+
+_PyTime_t __attribute__((noinline,noclone))
+_PyTime_AsMicroseconds(_PyTime_t t, _PyTime_round_t round)
+{
+  return _PyTime_Divide(t, 1000, round);
+}
+
+int main()
+{
+  if (_PyTime_AsMicroseconds (10000, _PyTime_ROUND_FLOOR) != 10)
+    abort ();
+  return 0;
+}
index c0e3b80..2d1eb70 100644 (file)
@@ -4804,6 +4804,9 @@ pass_pre::execute (function *fun)
   todo |= fini_eliminate ();
   loop_optimizer_finalize ();
 
+  /* Restore SSA info before tail-merging as that resets it as well.  */
+  scc_vn_restore_ssa_info ();
+
   /* TODO: tail_merge_optimize may merge all predecessors of a block, in which
      case we can merge the block with the remaining predecessor of the block.
      It should either:
@@ -4877,6 +4880,7 @@ pass_fre::execute (function *fun)
 
   todo |= fini_eliminate ();
 
+  scc_vn_restore_ssa_info ();
   free_scc_vn ();
 
   statistics_counter_event (fun, "Insertions", pre_stats.insertions);
index e61e033..f6735dd 100644 (file)
@@ -4306,26 +4306,19 @@ init_scc_vn (void)
     }
 }
 
+/* Restore SSA info that has been reset on value leaders.  */
+
 void
-free_scc_vn (void)
+scc_vn_restore_ssa_info (void)
 {
-  size_t i;
-
-  delete constant_to_value_id;
-  constant_to_value_id = NULL;
-  BITMAP_FREE (constant_value_ids);
-  shared_lookup_phiargs.release ();
-  shared_lookup_references.release ();
-  XDELETEVEC (rpo_numbers);
-
-  for (i = 0; i < num_ssa_names; i++)
+  for (unsigned i = 0; i < num_ssa_names; i++)
     {
       tree name = ssa_name (i);
       if (name
          && has_VN_INFO (name))
        {
          if (VN_INFO (name)->needs_insertion)
-           release_ssa_name (name);
+           ;
          else if (POINTER_TYPE_P (TREE_TYPE (name))
                   && VN_INFO (name)->info.ptr_info)
            SSA_NAME_PTR_INFO (name) = VN_INFO (name)->info.ptr_info;
@@ -4338,6 +4331,28 @@ free_scc_vn (void)
            }
        }
     }
+}
+
+void
+free_scc_vn (void)
+{
+  size_t i;
+
+  delete constant_to_value_id;
+  constant_to_value_id = NULL;
+  BITMAP_FREE (constant_value_ids);
+  shared_lookup_phiargs.release ();
+  shared_lookup_references.release ();
+  XDELETEVEC (rpo_numbers);
+
+  for (i = 0; i < num_ssa_names; i++)
+    {
+      tree name = ssa_name (i);
+      if (name
+         && has_VN_INFO (name)
+         && VN_INFO (name)->needs_insertion)
+       release_ssa_name (name);
+    }
   obstack_free (&vn_ssa_aux_obstack, NULL);
   vn_ssa_aux_table.release ();
 
index a3f9fa2..1f6af40 100644 (file)
@@ -204,6 +204,7 @@ extern vn_ssa_aux_t VN_INFO_GET (tree);
 tree vn_get_expr_for (tree);
 bool run_scc_vn (vn_lookup_kind);
 void free_scc_vn (void);
+void scc_vn_restore_ssa_info (void);
 tree vn_nary_op_lookup (tree, vn_nary_op_t *);
 tree vn_nary_op_lookup_stmt (gimple *, vn_nary_op_t *);
 tree vn_nary_op_lookup_pieces (unsigned int, enum tree_code,