jit-playback: Move argv-creation to its own function
[platform/upstream/gcc.git] / gcc / tree-ssa-threadupdate.c
index 2be3ab2..a8243ae 100644 (file)
@@ -22,8 +22,19 @@ along with GCC; see the file COPYING3.  If not see
 #include "coretypes.h"
 #include "tree.h"
 #include "flags.h"
-#include "basic-block.h"
+#include "predict.h"
+#include "vec.h"
+#include "hashtab.h"
+#include "hash-set.h"
+#include "machmode.h"
+#include "tm.h"
+#include "hard-reg-set.h"
+#include "input.h"
 #include "function.h"
+#include "dominance.h"
+#include "cfg.h"
+#include "cfganal.h"
+#include "basic-block.h"
 #include "hash-table.h"
 #include "tree-ssa-alias.h"
 #include "internal-fn.h"
@@ -394,13 +405,13 @@ copy_phi_arg_into_existing_phi (edge src_e, edge tgt_e)
   int tgt_idx = tgt_e->dest_idx;
 
   /* Iterate over each PHI in e->dest.  */
-  for (gimple_stmt_iterator gsi = gsi_start_phis (src_e->dest),
-                           gsi2 = gsi_start_phis (tgt_e->dest);
+  for (gphi_iterator gsi = gsi_start_phis (src_e->dest),
+                          gsi2 = gsi_start_phis (tgt_e->dest);
        !gsi_end_p (gsi);
        gsi_next (&gsi), gsi_next (&gsi2))
     {
-      gimple src_phi = gsi_stmt (gsi);
-      gimple dest_phi = gsi_stmt (gsi2);
+      gphi *src_phi = gsi.phi ();
+      gphi *dest_phi = gsi2.phi ();
       tree val = gimple_phi_arg_def (src_phi, src_idx);
       source_location locus = gimple_phi_arg_location (src_phi, src_idx);
 
@@ -419,14 +430,14 @@ get_value_locus_in_path (tree def, vec<jump_thread_edge *> *path,
                         basic_block bb, int idx, source_location *locus)
 {
   tree arg;
-  gimple def_phi;
+  gphi *def_phi;
   basic_block def_bb;
 
   if (path == NULL || idx == 0)
     return def;
 
-  def_phi = SSA_NAME_DEF_STMT (def);
-  if (gimple_code (def_phi) != GIMPLE_PHI)
+  def_phi = dyn_cast <gphi *> (SSA_NAME_DEF_STMT (def));
+  if (!def_phi)
     return def;
 
   def_bb = gimple_bb (def_phi);
@@ -463,12 +474,12 @@ static void
 copy_phi_args (basic_block bb, edge src_e, edge tgt_e,
               vec<jump_thread_edge *> *path, int idx)
 {
-  gimple_stmt_iterator gsi;
+  gphi_iterator gsi;
   int src_indx = src_e->dest_idx;
 
   for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple phi = gsi_stmt (gsi);
+      gphi *phi = gsi.phi ();
       tree def = gimple_phi_arg_def (phi, src_indx);
       source_location locus = gimple_phi_arg_location (phi, src_indx);
 
@@ -723,6 +734,11 @@ compute_path_counts (struct redirection_data *rd,
             nonpath_count += ein->count;
         }
     }
+
+  /* This is needed due to insane incoming frequencies.  */
+  if (path_in_freq > BB_FREQ_MAX)
+    path_in_freq = BB_FREQ_MAX;
+
   BITMAP_FREE (in_edge_srcs);
 
   /* Now compute the fraction of the total count coming into the first
@@ -2052,13 +2068,13 @@ fail:
 static bool
 phi_args_equal_on_edges (edge e1, edge e2)
 {
-  gimple_stmt_iterator gsi;
+  gphi_iterator gsi;
   int indx1 = e1->dest_idx;
   int indx2 = e2->dest_idx;
 
   for (gsi = gsi_start_phis (e1->dest); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple phi = gsi_stmt (gsi);
+      gphi *phi = gsi.phi ();
 
       if (!operand_equal_p (gimple_phi_arg_def (phi, indx1),
                            gimple_phi_arg_def (phi, indx2), 0))
@@ -2412,16 +2428,8 @@ thread_through_all_blocks (bool may_peel_loop_headers)
                /* Our path is still valid, thread it.  */
                if (e->aux)
                  {
-                   struct loop *loop = (*path)[0]->e->dest->loop_father;
-
                    if (thread_block ((*path)[0]->e->dest, false))
-                     {
-                       /* This jump thread likely totally scrambled this loop.
-                          So arrange for it to be fixed up.  */
-                       loop->header = NULL;
-                       loop->latch = NULL;
-                       e->aux = NULL;
-                     }
+                     e->aux = NULL;
                    else
                      {
                        delete_jump_thread_path (path);
@@ -2465,6 +2473,7 @@ delete_jump_thread_path (vec<jump_thread_edge *> *path)
   for (unsigned int i = 0; i < path->length (); i++)
     delete (*path)[i];
   path->release();
+  delete path;
 }
 
 /* Register a jump threading opportunity.  We queue up all the jump