When Diego committed rev 119760 he basically disabled the codepath
that switched virtual symbols to full rewrite.  Basically because
you could still trigger it by --param virtual-mappings-ratio=0.
As the code has not been excercised in the last 6(!) years I
opted to remove it as the underlying issue, very many virtual operands
vanished with the merge of alias-improvements.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

Richard.

2012-07-27  Richard Guenther  <rguent...@suse.de>

        * doc/invoke.texi (min-virtual-mappings, virtual-mappings-ratio):
        Remove param documentation.
        * params.def (PARAM_MIN_VIRTUAL_MAPPINGS,
        PARAM_VIRTUAL_MAPPINGS_TO_SYMS_RATIO): Remove.
        * tree-flow.h (mark_set_for_renaming): Remove.
        * tree-into-ssa.c (struct update_ssa_stats_d): Remove.
        (add_new_name_mapping): Remove bookkeeping code.
        (dump_update_ssa): Remove stats dumping code.
        (init_update_ssa): Remove stats allocation code.
        (delete_update_ssa): Remove stats freeing code.
        (mark_set_for_renaming): Remove.
        (switch_virtuals_to_full_rewrite_p): Likewise.
        (switch_virtuals_to_full_rewrite): Likewise.
        (update_ssa): Do not call switch_virtuals_to_full_rewrite.

Index: trunk/gcc/doc/invoke.texi
===================================================================
*** trunk.orig/gcc/doc/invoke.texi      2012-07-26 10:46:37.000000000 +0200
--- trunk/gcc/doc/invoke.texi   2012-07-27 12:52:05.774891497 +0200
*************** Small integer constants can use a shared
*** 9156,9173 ****
  compiler's memory usage and increasing its speed.  This sets the maximum
  value of a shared integer constant.  The default value is 256.
  
- @item min-virtual-mappings
- Specifies the minimum number of virtual mappings in the incremental
- SSA updater that should be registered to trigger the virtual mappings
- heuristic defined by virtual-mappings-ratio.  The default value is
- 100.
- 
- @item virtual-mappings-ratio
- If the number of virtual mappings is virtual-mappings-ratio bigger
- than the number of virtual symbols to be updated, then the incremental
- SSA updater switches to a full update for those symbols.  The default
- ratio is 3.
- 
  @item ssp-buffer-size
  The minimum size of buffers (i.e.@: arrays) that receive stack smashing
  protection when @option{-fstack-protection} is used.
--- 9156,9161 ----
Index: trunk/gcc/params.def
===================================================================
*** trunk.orig/gcc/params.def   2012-06-06 11:40:57.000000000 +0200
--- trunk/gcc/params.def        2012-07-27 12:51:33.096892630 +0200
*************** DEFPARAM (PARAM_INTEGER_SHARE_LIMIT,
*** 644,673 ****
          "The upper bound for sharing integer constants",
          256, 2, 2)
  
- /* Incremental SSA updates for virtual operands may be very slow if
-    there is a large number of mappings to process.  In those cases, it
-    is faster to rewrite the virtual symbols from scratch as if they
-    had been recently introduced.  This heuristic cannot be applied to
-    SSA mappings for real SSA names, only symbols kept in FUD chains.
- 
-    PARAM_MIN_VIRTUAL_MAPPINGS specifies the minimum number of virtual
-    mappings that should be registered to trigger the heuristic.
- 
-    PARAM_VIRTUAL_MAPPINGS_TO_SYMS_RATIO specifies the ratio between
-    mappings and symbols.  If the number of virtual mappings is
-    PARAM_VIRTUAL_MAPPINGS_TO_SYMS_RATIO bigger than the number of
-    virtual symbols to be updated, then the updater switches to a full
-    update for those symbols.  */
- DEFPARAM (PARAM_MIN_VIRTUAL_MAPPINGS,
-         "min-virtual-mappings",
-         "Minimum number of virtual mappings to consider switching to full 
virtual renames",
-         100, 0, 0)
- 
- DEFPARAM (PARAM_VIRTUAL_MAPPINGS_TO_SYMS_RATIO,
-         "virtual-mappings-ratio",
-         "Ratio between virtual mappings and virtual symbols to do full 
virtual renames",
-         3, 0, 0)
- 
  DEFPARAM (PARAM_SSP_BUFFER_SIZE,
          "ssp-buffer-size",
          "The lower bound for a buffer to be considered for stack smashing 
protection",
--- 644,649 ----
Index: trunk/gcc/tree-flow.h
===================================================================
*** trunk.orig/gcc/tree-flow.h  2012-07-26 15:47:35.000000000 +0200
--- trunk/gcc/tree-flow.h       2012-07-27 12:46:26.098903253 +0200
*************** bool name_registered_for_update_p (tree)
*** 575,581 ****
  void release_ssa_name_after_update_ssa (tree);
  void compute_global_livein (bitmap, bitmap);
  void mark_sym_for_renaming (tree);
- void mark_set_for_renaming (bitmap);
  bool symbol_marked_for_renaming (tree);
  tree get_current_def (tree);
  void set_current_def (tree, tree);
--- 575,580 ----
Index: trunk/gcc/tree-into-ssa.c
===================================================================
*** trunk.orig/gcc/tree-into-ssa.c      2012-07-27 12:44:02.000000000 +0200
--- trunk/gcc/tree-into-ssa.c   2012-07-27 12:52:09.835891373 +0200
*************** static htab_t repl_tbl;
*** 145,165 ****
     NULL if they need to be initialized by register_new_name_mapping.  */
  static struct function *update_ssa_initialized_fn = NULL;
  
- /* Statistics kept by update_ssa to use in the virtual mapping
-    heuristic.  If the number of virtual mappings is beyond certain
-    threshold, the updater will switch from using the mappings into
-    renaming the virtual symbols from scratch.  In some cases, the
-    large number of name mappings for virtual names causes significant
-    slowdowns in the PHI insertion code.  */
- struct update_ssa_stats_d
- {
-   unsigned num_virtual_mappings;
-   unsigned num_total_mappings;
-   bitmap virtual_symbols;
-   unsigned num_virtual_symbols;
- };
- static struct update_ssa_stats_d update_ssa_stats;
- 
  /* Global data to attach to the main dominator walk structure.  */
  struct mark_def_sites_global_data
  {
--- 145,150 ----
*************** add_new_name_mapping (tree new_tree, tre
*** 667,692 ****
    /* OLD and NEW_TREE must be different SSA names for the same symbol.  */
    gcc_assert (new_tree != old && SSA_NAME_VAR (new_tree) == SSA_NAME_VAR 
(old));
  
-   /* If this mapping is for virtual names, we will need to update
-      virtual operands.  If this is a mapping for .MEM, then we gather
-      the symbols associated with each name.  */
-   if (!is_gimple_reg (new_tree))
-     {
-       tree sym;
- 
-       update_ssa_stats.num_virtual_mappings++;
-       update_ssa_stats.num_virtual_symbols++;
- 
-       /* Keep counts of virtual mappings and symbols to use in the
-        virtual mapping heuristic.  If we have large numbers of
-        virtual mappings for a relatively low number of symbols, it
-        will make more sense to rename the symbols from scratch.
-        Otherwise, the insertion of PHI nodes for each of the old
-        names in these mappings will be very slow.  */
-       sym = SSA_NAME_VAR (new_tree);
-       bitmap_set_bit (update_ssa_stats.virtual_symbols, DECL_UID (sym));
-     }
- 
    /* We may need to grow NEW_SSA_NAMES and OLD_SSA_NAMES because our
       caller may have created new names since the set was created.  */
    if (new_ssa_names->n_bits <= num_ssa_names - 1)
--- 652,657 ----
*************** add_new_name_mapping (tree new_tree, tre
*** 709,717 ****
    SET_BIT (new_ssa_names, SSA_NAME_VERSION (new_tree));
    SET_BIT (old_ssa_names, SSA_NAME_VERSION (old));
  
-   /* Update mapping counter to use in the virtual mapping heuristic.  */
-   update_ssa_stats.num_total_mappings++;
- 
    timevar_pop (TV_TREE_SSA_INCREMENTAL);
  }
  
--- 674,679 ----
*************** dump_update_ssa (FILE *file)
*** 2831,2848 ****
  
        EXECUTE_IF_SET_IN_SBITMAP (new_ssa_names, 0, i, sbi)
        dump_names_replaced_by (file, ssa_name (i));
- 
-       fprintf (file, "\n");
-       fprintf (file, "Number of virtual NEW -> OLD mappings: %7u\n",
-              update_ssa_stats.num_virtual_mappings);
-       fprintf (file, "Number of real NEW -> OLD mappings:    %7u\n",
-              update_ssa_stats.num_total_mappings
-              - update_ssa_stats.num_virtual_mappings);
-       fprintf (file, "Number of total NEW -> OLD mappings:   %7u\n",
-              update_ssa_stats.num_total_mappings);
- 
-       fprintf (file, "\nNumber of virtual symbols: %u\n",
-              update_ssa_stats.num_virtual_symbols);
      }
  
    if (!bitmap_empty_p (SYMS_TO_RENAME (cfun)))
--- 2793,2798 ----
*************** init_update_ssa (struct function *fn)
*** 2890,2897 ****
  
    repl_tbl = htab_create (20, repl_map_hash, repl_map_eq, repl_map_free);
    names_to_release = NULL;
-   memset (&update_ssa_stats, 0, sizeof (update_ssa_stats));
-   update_ssa_stats.virtual_symbols = BITMAP_ALLOC (NULL);
    update_ssa_initialized_fn = fn;
  }
  
--- 2840,2845 ----
*************** delete_update_ssa (void)
*** 2914,2920 ****
    repl_tbl = NULL;
  
    bitmap_clear (SYMS_TO_RENAME (update_ssa_initialized_fn));
-   BITMAP_FREE (update_ssa_stats.virtual_symbols);
  
    if (names_to_release)
      {
--- 2862,2867 ----
*************** mark_sym_for_renaming (tree sym)
*** 2998,3019 ****
  }
  
  
- /* Register all the symbols in SET to be renamed by update_ssa.  */
- 
- void
- mark_set_for_renaming (bitmap set)
- {
-   bitmap_iterator bi;
-   unsigned i;
- 
-   if (set == NULL || bitmap_empty_p (set))
-     return;
- 
-   EXECUTE_IF_SET_IN_BITMAP (set, 0, i, bi)
-     mark_sym_for_renaming (referenced_var (i));
- }
- 
- 
  /* Return true if there is any work to be done by update_ssa
     for function FN.  */
  
--- 2945,2950 ----
*************** insert_updated_phi_nodes_for (tree var,
*** 3175,3247 ****
  }
  
  
- /* Heuristic to determine whether SSA name mappings for virtual names
-    should be discarded and their symbols rewritten from scratch.  When
-    there is a large number of mappings for virtual names, the
-    insertion of PHI nodes for the old names in the mappings takes
-    considerable more time than if we inserted PHI nodes for the
-    symbols instead.
- 
-    Currently the heuristic takes these stats into account:
- 
-       - Number of mappings for virtual SSA names.
-       - Number of distinct virtual symbols involved in those mappings.
- 
-    If the number of virtual mappings is much larger than the number of
-    virtual symbols, then it will be faster to compute PHI insertion
-    spots for the symbols.  Even if this involves traversing the whole
-    CFG, which is what happens when symbols are renamed from scratch.  */
- 
- static bool
- switch_virtuals_to_full_rewrite_p (void)
- {
-   if (update_ssa_stats.num_virtual_mappings < (unsigned) MIN_VIRTUAL_MAPPINGS)
-     return false;
- 
-   if (update_ssa_stats.num_virtual_mappings
-       > (unsigned) VIRTUAL_MAPPINGS_TO_SYMS_RATIO
-         * update_ssa_stats.num_virtual_symbols)
-     return true;
- 
-   return false;
- }
- 
- 
- /* Remove every virtual mapping and mark all the affected virtual
-    symbols for renaming.  */
- 
- static void
- switch_virtuals_to_full_rewrite (void)
- {
-   unsigned i = 0;
-   sbitmap_iterator sbi;
- 
-   if (dump_file)
-     {
-       fprintf (dump_file, "\nEnabled virtual name mapping heuristic.\n");
-       fprintf (dump_file, "\tNumber of virtual mappings:       %7u\n",
-              update_ssa_stats.num_virtual_mappings);
-       fprintf (dump_file, "\tNumber of unique virtual symbols: %7u\n",
-              update_ssa_stats.num_virtual_symbols);
-       fprintf (dump_file, "Updating FUD-chains from top of CFG will be "
-                         "faster than processing\nthe name mappings.\n\n");
-     }
- 
-   /* Remove all virtual names from NEW_SSA_NAMES and OLD_SSA_NAMES.
-      Note that it is not really necessary to remove the mappings from
-      REPL_TBL, that would only waste time.  */
-   EXECUTE_IF_SET_IN_SBITMAP (new_ssa_names, 0, i, sbi)
-     if (!is_gimple_reg (ssa_name (i)))
-       RESET_BIT (new_ssa_names, i);
- 
-   EXECUTE_IF_SET_IN_SBITMAP (old_ssa_names, 0, i, sbi)
-     if (!is_gimple_reg (ssa_name (i)))
-       RESET_BIT (old_ssa_names, i);
- 
-   mark_set_for_renaming (update_ssa_stats.virtual_symbols);
- }
- 
- 
  /* Given a set of newly created SSA names (NEW_SSA_NAMES) and a set of
     existing SSA names (OLD_SSA_NAMES), update the SSA form so that:
  
--- 3106,3111 ----
*************** update_ssa (unsigned update_flags)
*** 3370,3380 ****
        def_blocks = NULL;
      }
  
-   /* Heuristic to avoid massive slow downs when the replacement
-      mappings include lots of virtual names.  */
-   if (insert_phi_p && switch_virtuals_to_full_rewrite_p ())
-     switch_virtuals_to_full_rewrite ();
- 
    /* If there are names defined in the replacement table, prepare
       definition and use sites for all the names in NEW_SSA_NAMES and
       OLD_SSA_NAMES.  */
--- 3234,3239 ----

Reply via email to