This makes rewriting decls into SSA form via SSA updating fully
transparent and no longer requiring mark_sym_for_renaming calls.
Much like the operand scanner marks virtual SSA form for renaming
automagically if it adds new virtual operands the following patch
makes sure it does so for real operands as well.  Previously
if you'd forgot to mark such operands for renaming manually the
first SSA verification phase would have complained.  So this
patch removes burden from the programmer and in turn even makes
the compiler faster.

I did not yet touch the remaining mark_sym_for_renaming calls
which are still necessary if you want to update the virtual SSA
web in some cases.  A followup will merge the still existing
very many variants of code that do so and unify those calls
(maybe removing a few unnecessary ones).

Bootstrap and regtest is running on x86_64-unknown-linux-gnu.

Scary code removed in matrix-reorg.c reminds me of removing that
useless beast ...

Thanks,
Richard.

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

        * tree-flow.h (struct gimple_df): Remove syms_to_rename member,
        add ssa_renaming_needed and rename_vops flags.
        (SYMS_TO_RENAME): Remove.
        (symbol_marked_for_renaming): Likewise.
        (mark_virtual_ops_for_renaming): Likewise.
        * tree-into-ssa.c (symbols_to_rename_set, symbols_to_rename):
        New globals.
        (mark_for_renaming, marked_for_renaming): New functions.
        (symbol_marked_for_renaming): Remove.
        (dump_currdefs): Adjust.
        (maybe_replace_use): Likewise.
        (maybe_replace_use_in_debug_stmt): Likewise.
        (maybe_register_def): Likewise.
        (rewrite_update_phi_arguments): Likewise.
        (rewrite_update_enter_block): Likewise.
        (fini_ssa_renamer): Clear update SSA status here ...
        (delete_update_ssa): ... not here.  Free rename set.
        (prepare_block_for_update): Compute which decls need renaming.
        (dump_update_ssa): Adjust.
        (mark_sym_for_renaming): Adjust update SSA status for virtuals.
        (need_ssa_update_p): Adjust.
        (insert_updated_phi_nodes_for): Likewise.
        (update_ssa): Likewise.
        * tree-ssa-operands.c (finalize_ssa_defs): Adjust update SSA status
        for virtual and real operands.
        (finalize_ssa_uses): Likewise.
        * tree-ssanames.c (init_ssanames): Adjust.
        * tree-ssa.c (maybe_rewrite_mem_ref_base, maybe_optimize_var,
        execute_update_addresses_taken): Add bitmap to keep track of which
        candidates are suitable for rewriting and later renaming by SSA
        update.
        * matrix-reorg.c (transform_access_sites): Do not rename all defs.
        * tree-dfa.c (make_rename_temp): Do not mark real operands for renaming.
        * cgraphunit.c (assemble_thunk): Likewise.
        * gimplify.c (gimple_regimplify_operands): Likewise.
        (force_gimple_operand_1): Likewise.
        * ipa-prop.c (ipa_modify_formal_parameters): Likewise.
        * tree-inline.c (declare_return_variable): Likewise.
        * tree-parloops.c (separate_decls_in_region_stmt): Do not call
        mark_virtual_ops_for_renaming.
        (create_stores_for_reduction): Likewise.
        (create_loads_and_stores_for_name): Likewise.
        * tree-predcom.c (mark_virtual_ops_for_renaming): Remove.
        (initialize_root_vars_lm): Do not call mark_virtual_ops_for_renaming.
        (execute_load_motion): Likewise.
        (remove_stmt): Likewise.
        (execute_pred_commoning_chain): Likewise.
        * tree-sra.c (create_access_replacement): Do not rename real
        operands.
        (get_unrenamed_access_replacement): Unify with ...
        (get_access_replacement): ... this.
        (get_repl_default_def_ssa_name): Adjust.
        * tree-ssa-loop-im.c (move_computations_stmt): Manually update
        virtual SSA form.
        (rewrite_mem_ref_loc): Do not call mark_virtual_ops_for_renaming.
        * tree-ssa-loop-prefetch.c (emit_mfence_after_loop): Likewise.

Index: trunk/gcc/tree-flow.h
===================================================================
*** trunk.orig/gcc/tree-flow.h  2012-07-31 11:36:00.000000000 +0200
--- trunk/gcc/tree-flow.h       2012-07-31 13:13:18.190881662 +0200
*************** struct GTY(()) gimple_df {
*** 77,85 ****
       for this variable with an empty defining statement.  */
    htab_t GTY((param_is (union tree_node))) default_defs;
  
!   /* Symbols whose SSA form needs to be updated or created for the first
!      time.  */
!   bitmap syms_to_rename;
  
    /* True if the code is in ssa form.  */
    unsigned int in_ssa_p : 1;
--- 77,87 ----
       for this variable with an empty defining statement.  */
    htab_t GTY((param_is (union tree_node))) default_defs;
  
!   /* True if there are any symbols that need to be renamed.  */
!   unsigned int ssa_renaming_needed : 1;
! 
!   /* True if all virtual operands need to be renamed.  */
!   unsigned int rename_vops : 1;
  
    /* True if the code is in ssa form.  */
    unsigned int in_ssa_p : 1;
*************** struct GTY(()) gimple_df {
*** 100,106 ****
  #define SSANAMES(fun) (fun)->gimple_df->ssa_names
  #define MODIFIED_NORETURN_CALLS(fun) (fun)->gimple_df->modified_noreturn_calls
  #define DEFAULT_DEFS(fun) (fun)->gimple_df->default_defs
- #define SYMS_TO_RENAME(fun) (fun)->gimple_df->syms_to_rename
  
  typedef struct
  {
--- 102,107 ----
*************** bool name_registered_for_update_p (tree)
*** 565,571 ****
  void release_ssa_name_after_update_ssa (tree);
  void compute_global_livein (bitmap, bitmap);
  void mark_sym_for_renaming (tree);
- bool symbol_marked_for_renaming (tree);
  tree get_current_def (tree);
  void set_current_def (tree, tree);
  
--- 566,571 ----
*************** void tree_transform_and_unroll_loop (str
*** 715,721 ****
                                     transform_callback, void *);
  bool contains_abnormal_ssa_name_p (tree);
  bool stmt_dominates_stmt_p (gimple, gimple);
- void mark_virtual_ops_for_renaming (gimple);
  
  /* In tree-ssa-dce.c */
  void mark_virtual_operand_for_renaming (tree);
--- 715,720 ----
Index: trunk/gcc/tree-into-ssa.c
===================================================================
*** trunk.orig/gcc/tree-into-ssa.c      2012-07-31 11:36:00.000000000 +0200
--- trunk/gcc/tree-into-ssa.c   2012-07-31 13:39:50.224826534 +0200
*************** extern void debug_defs_stack (int);
*** 227,232 ****
--- 227,259 ----
  extern void dump_currdefs (FILE *);
  extern void debug_currdefs (void);
  
+ 
+ /* The set of symbols we ought to re-write into SSA form in update_ssa.  */
+ static bitmap symbols_to_rename_set;
+ static VEC(tree,heap) *symbols_to_rename;
+ 
+ /* Mark SYM for renaming.  */
+ 
+ static void
+ mark_for_renaming (tree sym)
+ {
+   if (!symbols_to_rename_set)
+     symbols_to_rename_set = BITMAP_ALLOC (NULL);
+   if (bitmap_set_bit (symbols_to_rename_set, DECL_UID (sym)))
+     VEC_safe_push (tree, heap, symbols_to_rename, sym);
+ }
+ 
+ /* Return true if SYM is marked for renaming.  */
+ 
+ static bool
+ marked_for_renaming (tree sym)
+ {
+   if (!symbols_to_rename_set)
+     return false;
+   return bitmap_bit_p (symbols_to_rename_set, DECL_UID (sym));
+ }
+ 
+ 
  /* Return true if STMT needs to be rewritten.  When renaming a subset
     of the variables, not all statements will be processed.  This is
     decided in mark_def_sites.  */
*************** set_livein_block (tree var, basic_block
*** 574,588 ****
  }
  
  
- /* Return true if symbol SYM is marked for renaming.  */
- 
- bool
- symbol_marked_for_renaming (tree sym)
- {
-   return bitmap_bit_p (SYMS_TO_RENAME (cfun), DECL_UID (sym));
- }
- 
- 
  /* Return true if NAME is in OLD_SSA_NAMES.  */
  
  static inline bool
--- 601,606 ----
*************** debug_defs_stack (int n)
*** 1636,1658 ****
  void
  dump_currdefs (FILE *file)
  {
!   referenced_var_iterator i;
    tree var;
  
    fprintf (file, "\n\nCurrent reaching definitions\n\n");
!   FOR_EACH_REFERENCED_VAR (cfun, var, i)
!     if (SYMS_TO_RENAME (cfun) == NULL
!       || bitmap_bit_p (SYMS_TO_RENAME (cfun), DECL_UID (var)))
!       {
!       fprintf (file, "CURRDEF (");
!       print_generic_expr (file, var, 0);
!       fprintf (file, ") = ");
!       if (get_current_def (var))
!         print_generic_expr (file, get_current_def (var), 0);
!       else
!         fprintf (file, "<NIL>");
!       fprintf (file, "\n");
!       }
  }
  
  
--- 1654,1677 ----
  void
  dump_currdefs (FILE *file)
  {
!   unsigned i;
    tree var;
  
+   if (VEC_empty (tree, symbols_to_rename))
+     return;
+ 
    fprintf (file, "\n\nCurrent reaching definitions\n\n");
!   FOR_EACH_VEC_ELT (tree, symbols_to_rename, i, var)
!     {
!       fprintf (file, "CURRDEF (");
!       print_generic_expr (file, var, 0);
!       fprintf (file, ") = ");
!       if (get_current_def (var))
!       print_generic_expr (file, get_current_def (var), 0);
!       else
!       fprintf (file, "<NIL>");
!       fprintf (file, "\n");
!     }
  }
  
  
*************** maybe_replace_use (use_operand_p use_p)
*** 1830,1836 ****
    tree use = USE_FROM_PTR (use_p);
    tree sym = DECL_P (use) ? use : SSA_NAME_VAR (use);
  
!   if (symbol_marked_for_renaming (sym))
      rdef = get_reaching_def (sym);
    else if (is_old_name (use))
      rdef = get_reaching_def (use);
--- 1849,1855 ----
    tree use = USE_FROM_PTR (use_p);
    tree sym = DECL_P (use) ? use : SSA_NAME_VAR (use);
  
!   if (marked_for_renaming (sym))
      rdef = get_reaching_def (sym);
    else if (is_old_name (use))
      rdef = get_reaching_def (use);
*************** maybe_replace_use_in_debug_stmt (use_ope
*** 1850,1856 ****
    tree use = USE_FROM_PTR (use_p);
    tree sym = DECL_P (use) ? use : SSA_NAME_VAR (use);
  
!   if (symbol_marked_for_renaming (sym))
      rdef = get_current_def (sym);
    else if (is_old_name (use))
      {
--- 1869,1875 ----
    tree use = USE_FROM_PTR (use_p);
    tree sym = DECL_P (use) ? use : SSA_NAME_VAR (use);
  
!   if (marked_for_renaming (sym))
      rdef = get_current_def (sym);
    else if (is_old_name (use))
      {
*************** maybe_register_def (def_operand_p def_p,
*** 1886,1892 ****
  
    /* If DEF is a naked symbol that needs renaming, create a new
       name for it.  */
!   if (symbol_marked_for_renaming (sym))
      {
        if (DECL_P (def))
        {
--- 1905,1911 ----
  
    /* If DEF is a naked symbol that needs renaming, create a new
       name for it.  */
!   if (marked_for_renaming (sym))
      {
        if (DECL_P (def))
        {
*************** rewrite_update_phi_arguments (basic_bloc
*** 2077,2083 ****
            {
              tree sym = DECL_P (arg) ? arg : SSA_NAME_VAR (arg);
  
!             if (symbol_marked_for_renaming (sym))
                reaching_def = get_reaching_def (sym);
              else if (is_old_name (arg))
                reaching_def = get_reaching_def (arg);
--- 2096,2102 ----
            {
              tree sym = DECL_P (arg) ? arg : SSA_NAME_VAR (arg);
  
!             if (marked_for_renaming (sym))
                reaching_def = get_reaching_def (sym);
              else if (is_old_name (arg))
                reaching_def = get_reaching_def (arg);
*************** rewrite_update_enter_block (struct dom_w
*** 2154,2160 ****
        lhs = gimple_phi_result (phi);
        lhs_sym = SSA_NAME_VAR (lhs);
  
!       if (symbol_marked_for_renaming (lhs_sym))
        register_new_update_single (lhs, lhs_sym);
        else
        {
--- 2173,2179 ----
        lhs = gimple_phi_result (phi);
        lhs_sym = SSA_NAME_VAR (lhs);
  
!       if (marked_for_renaming (lhs_sym))
        register_new_update_single (lhs, lhs_sym);
        else
        {
*************** fini_ssa_renamer (void)
*** 2369,2374 ****
--- 2388,2395 ----
  
    bitmap_obstack_release (&update_ssa_obstack);
  
+   cfun->gimple_df->ssa_renaming_needed = 0;
+   cfun->gimple_df->rename_vops = 0;
    cfun->gimple_df->in_ssa_p = true;
  }
  
*************** mark_use_interesting (tree var, gimple s
*** 2526,2532 ****
  
  
  /* Do a dominator walk starting at BB processing statements that
!    reference symbols in SYMS_TO_RENAME.  This is very similar to
     mark_def_sites, but the scan handles statements whose operands may
     already be SSA names.
  
--- 2547,2553 ----
  
  
  /* Do a dominator walk starting at BB processing statements that
!    reference symbols in SSA operands.  This is very similar to
     mark_def_sites, but the scan handles statements whose operands may
     already be SSA names.
  
*************** prepare_block_for_update (basic_block bb
*** 2559,2567 ****
  
        lhs_sym = DECL_P (lhs) ? lhs : SSA_NAME_VAR (lhs);
  
!       if (!symbol_marked_for_renaming (lhs_sym))
        continue;
  
        mark_def_interesting (lhs_sym, phi, bb, insert_phi_p);
  
        /* Mark the uses in phi nodes as interesting.  It would be more correct
--- 2580,2592 ----
  
        lhs_sym = DECL_P (lhs) ? lhs : SSA_NAME_VAR (lhs);
  
!       if (TREE_CODE (lhs) == SSA_NAME
!         && (TREE_CODE (lhs_sym) != VAR_DECL
!             || !VAR_DECL_IS_VIRTUAL_OPERAND (lhs_sym)
!             || !cfun->gimple_df->rename_vops))
        continue;
  
+       mark_for_renaming (lhs_sym);
        mark_def_interesting (lhs_sym, phi, bb, insert_phi_p);
  
        /* Mark the uses in phi nodes as interesting.  It would be more correct
*************** prepare_block_for_update (basic_block bb
*** 2585,2604 ****
  
        stmt = gsi_stmt (si);
  
!       FOR_EACH_SSA_USE_OPERAND (use_p, stmt, i, SSA_OP_ALL_USES)
        {
!         tree use = USE_FROM_PTR (use_p);
          tree sym = DECL_P (use) ? use : SSA_NAME_VAR (use);
!         if (symbol_marked_for_renaming (sym))
!           mark_use_interesting (sym, stmt, bb, insert_phi_p);
        }
  
!       FOR_EACH_SSA_DEF_OPERAND (def_p, stmt, i, SSA_OP_ALL_DEFS)
        {
!         tree def = DEF_FROM_PTR (def_p);
          tree sym = DECL_P (def) ? def : SSA_NAME_VAR (def);
!         if (symbol_marked_for_renaming (sym))
!           mark_def_interesting (sym, stmt, bb, insert_phi_p);
        }
      }
  
--- 2610,2649 ----
  
        stmt = gsi_stmt (si);
  
!       if (cfun->gimple_df->rename_vops
!         && gimple_vuse (stmt))
        {
!         tree use = gimple_vuse (stmt);
          tree sym = DECL_P (use) ? use : SSA_NAME_VAR (use);
!         mark_for_renaming (sym);
!         mark_use_interesting (sym, stmt, bb, insert_phi_p);
        }
  
!       FOR_EACH_SSA_USE_OPERAND (use_p, stmt, i, SSA_OP_USE)
        {
!         tree use = USE_FROM_PTR (use_p);
!         if (!DECL_P (use))
!           continue;
!         mark_for_renaming (use);
!         mark_use_interesting (use, stmt, bb, insert_phi_p);
!       }
! 
!       if (cfun->gimple_df->rename_vops
!         && gimple_vdef (stmt))
!       {
!         tree def = gimple_vdef (stmt);
          tree sym = DECL_P (def) ? def : SSA_NAME_VAR (def);
!         mark_for_renaming (sym);
!         mark_def_interesting (sym, stmt, bb, insert_phi_p);
!       }
! 
!       FOR_EACH_SSA_DEF_OPERAND (def_p, stmt, i, SSA_OP_DEF)
!       {
!         tree def = DEF_FROM_PTR (def_p);
!         if (!DECL_P (def))
!           continue;
!         mark_for_renaming (def);
!         mark_def_interesting (def, stmt, bb, insert_phi_p);
        }
      }
  
*************** dump_update_ssa (FILE *file)
*** 2757,2766 ****
        dump_names_replaced_by (file, ssa_name (i));
      }
  
!   if (!bitmap_empty_p (SYMS_TO_RENAME (cfun)))
      {
        fprintf (file, "\nSymbols to be put in SSA form\n");
!       dump_decl_set (file, SYMS_TO_RENAME (cfun));
        fprintf (file, "\n");
      }
  
--- 2802,2811 ----
        dump_names_replaced_by (file, ssa_name (i));
      }
  
!   if (symbols_to_rename_set && !bitmap_empty_p (symbols_to_rename_set))
      {
        fprintf (file, "\nSymbols to be put in SSA form\n");
!       dump_decl_set (file, symbols_to_rename_set);
        fprintf (file, "\n");
      }
  
*************** delete_update_ssa (void)
*** 2821,2827 ****
    sbitmap_free (new_ssa_names);
    new_ssa_names = NULL;
  
!   bitmap_clear (SYMS_TO_RENAME (update_ssa_initialized_fn));
  
    if (names_to_release)
      {
--- 2866,2874 ----
    sbitmap_free (new_ssa_names);
    new_ssa_names = NULL;
  
!   BITMAP_FREE (symbols_to_rename_set);
!   symbols_to_rename_set = NULL;
!   VEC_free (tree, heap, symbols_to_rename);
  
    if (names_to_release)
      {
*************** register_new_name_mapping (tree new_tree
*** 2902,2909 ****
  void
  mark_sym_for_renaming (tree sym)
  {
!   if (cfun->gimple_df->in_ssa_p)
!     bitmap_set_bit (SYMS_TO_RENAME (cfun), DECL_UID (sym));
  }
  
  
--- 2949,2960 ----
  void
  mark_sym_for_renaming (tree sym)
  {
!   if (TREE_CODE (sym) == VAR_DECL
!       && VAR_DECL_IS_VIRTUAL_OPERAND (sym))
!     {
!       cfun->gimple_df->ssa_renaming_needed = 1;
!       cfun->gimple_df->rename_vops = 1;
!     }
  }
  
  
*************** need_ssa_update_p (struct function *fn)
*** 2915,2922 ****
  {
    gcc_assert (fn != NULL);
    return (update_ssa_initialized_fn == fn
!         || (fn->gimple_df
!             && !bitmap_empty_p (SYMS_TO_RENAME (fn))));
  }
  
  /* Return true if name N has been registered in the replacement table.  */
--- 2966,2972 ----
  {
    gcc_assert (fn != NULL);
    return (update_ssa_initialized_fn == fn
!         || (fn->gimple_df && fn->gimple_df->ssa_renaming_needed));
  }
  
  /* Return true if name N has been registered in the replacement table.  */
*************** insert_updated_phi_nodes_for (tree var,
*** 2983,2989 ****
    if (TREE_CODE (var) == SSA_NAME)
      gcc_checking_assert (is_old_name (var));
    else
!     gcc_checking_assert (symbol_marked_for_renaming (var));
  
    /* Get all the definition sites for VAR.  */
    db = find_def_blocks_for (var);
--- 3033,3039 ----
    if (TREE_CODE (var) == SSA_NAME)
      gcc_checking_assert (is_old_name (var));
    else
!     gcc_checking_assert (marked_for_renaming (var));
  
    /* Get all the definition sites for VAR.  */
    db = find_def_blocks_for (var);
*************** update_ssa (unsigned update_flags)
*** 3127,3132 ****
--- 3177,3183 ----
    unsigned i = 0;
    bool insert_phi_p;
    sbitmap_iterator sbi;
+   tree sym;
  
    if (!need_ssa_update_p (cfun))
      return;
*************** update_ssa (unsigned update_flags)
*** 3176,3187 ****
         removal, and there are no symbols to rename, then there's
         nothing else to do.  */
        if (sbitmap_first_set_bit (new_ssa_names) < 0
!         && bitmap_empty_p (SYMS_TO_RENAME (cfun)))
        goto done;
      }
  
    /* Next, determine the block at which to start the renaming process.  */
!   if (!bitmap_empty_p (SYMS_TO_RENAME (cfun)))
      {
        /* If we rename bare symbols initialize the mapping to
           auxiliar info we need to keep track of.  */
--- 3227,3238 ----
         removal, and there are no symbols to rename, then there's
         nothing else to do.  */
        if (sbitmap_first_set_bit (new_ssa_names) < 0
!         && !cfun->gimple_df->ssa_renaming_needed)
        goto done;
      }
  
    /* Next, determine the block at which to start the renaming process.  */
!   if (cfun->gimple_df->ssa_renaming_needed)
      {
        /* If we rename bare symbols initialize the mapping to
           auxiliar info we need to keep track of.  */
*************** update_ssa (unsigned update_flags)
*** 3195,3201 ****
        start_bb = ENTRY_BLOCK_PTR;
  
        /* Traverse the CFG looking for existing definitions and uses of
!        symbols in SYMS_TO_RENAME.  Mark interesting blocks and
         statements and set local live-in information for the PHI
         placement heuristics.  */
        prepare_block_for_update (start_bb, insert_phi_p);
--- 3246,3252 ----
        start_bb = ENTRY_BLOCK_PTR;
  
        /* Traverse the CFG looking for existing definitions and uses of
!        symbols in SSA operands.  Mark interesting blocks and
         statements and set local live-in information for the PHI
         placement heuristics.  */
        prepare_block_for_update (start_bb, insert_phi_p);
*************** update_ssa (unsigned update_flags)
*** 3210,3216 ****
  
    /* If requested, insert PHI nodes at the iterated dominance frontier
       of every block, creating new definitions for names in OLD_SSA_NAMES
!      and for symbols in SYMS_TO_RENAME.  */
    if (insert_phi_p)
      {
        bitmap_head *dfs;
--- 3261,3267 ----
  
    /* If requested, insert PHI nodes at the iterated dominance frontier
       of every block, creating new definitions for names in OLD_SSA_NAMES
!      and for symbols found.  */
    if (insert_phi_p)
      {
        bitmap_head *dfs;
*************** update_ssa (unsigned update_flags)
*** 3239,3246 ****
          sbitmap_free (tmp);
        }
  
!       EXECUTE_IF_SET_IN_BITMAP (SYMS_TO_RENAME (cfun), 0, i, bi)
!       insert_updated_phi_nodes_for (referenced_var (i), dfs, blocks_to_update,
                                      update_flags);
  
        FOR_EACH_BB (bb)
--- 3290,3297 ----
          sbitmap_free (tmp);
        }
  
!       FOR_EACH_VEC_ELT (tree, symbols_to_rename, i, sym)
!       insert_updated_phi_nodes_for (sym, dfs, blocks_to_update,
                                      update_flags);
  
        FOR_EACH_BB (bb)
*************** update_ssa (unsigned update_flags)
*** 3260,3267 ****
    EXECUTE_IF_SET_IN_SBITMAP (old_ssa_names, 0, i, sbi)
      set_current_def (ssa_name (i), NULL_TREE);
  
!   EXECUTE_IF_SET_IN_BITMAP (SYMS_TO_RENAME (cfun), 0, i, bi)
!     set_current_def (referenced_var (i), NULL_TREE);
  
    /* Now start the renaming process at START_BB.  */
    interesting_blocks = sbitmap_alloc (last_basic_block);
--- 3311,3318 ----
    EXECUTE_IF_SET_IN_SBITMAP (old_ssa_names, 0, i, sbi)
      set_current_def (ssa_name (i), NULL_TREE);
  
!   FOR_EACH_VEC_ELT (tree, symbols_to_rename, i, sym)
!     set_current_def (sym, NULL_TREE);
  
    /* Now start the renaming process at START_BB.  */
    interesting_blocks = sbitmap_alloc (last_basic_block);
Index: trunk/gcc/tree-ssa-operands.c
===================================================================
*** trunk.orig/gcc/tree-ssa-operands.c  2012-07-31 11:34:18.000000000 +0200
--- trunk/gcc/tree-ssa-operands.c       2012-07-31 11:36:00.932083758 +0200
*************** finalize_ssa_defs (gimple stmt)
*** 416,422 ****
    /* If we have a non-SSA_NAME VDEF, mark it for renaming.  */
    if (gimple_vdef (stmt)
        && TREE_CODE (gimple_vdef (stmt)) != SSA_NAME)
!     mark_sym_for_renaming (gimple_vdef (stmt));
  
    /* Check for the common case of 1 def that hasn't changed.  */
    if (old_ops && old_ops->next == NULL && num == 1
--- 416,425 ----
    /* If we have a non-SSA_NAME VDEF, mark it for renaming.  */
    if (gimple_vdef (stmt)
        && TREE_CODE (gimple_vdef (stmt)) != SSA_NAME)
!     {
!       cfun->gimple_df->rename_vops = 1;
!       cfun->gimple_df->ssa_renaming_needed = 1;
!     }
  
    /* Check for the common case of 1 def that hasn't changed.  */
    if (old_ops && old_ops->next == NULL && num == 1
*************** finalize_ssa_defs (gimple stmt)
*** 432,438 ****
  
    /* If there is anything remaining in the build_defs list, simply emit it.  
*/
    for ( ; new_i < num; new_i++)
!     last = add_def_op ((tree *) VEC_index (tree, build_defs, new_i), last);
  
    /* Now set the stmt's operands.  */
    gimple_set_def_ops (stmt, new_list.next);
--- 435,446 ----
  
    /* If there is anything remaining in the build_defs list, simply emit it.  
*/
    for ( ; new_i < num; new_i++)
!     {
!       tree *op = (tree *) VEC_index (tree, build_defs, new_i);
!       if (DECL_P (*op))
!       cfun->gimple_df->ssa_renaming_needed = 1;
!       last = add_def_op (op, last);
!     }
  
    /* Now set the stmt's operands.  */
    gimple_set_def_ops (stmt, new_list.next);
*************** finalize_ssa_uses (gimple stmt)
*** 487,500 ****
        && gimple_vuse (stmt) == NULL_TREE)
      {
        gimple_set_vuse (stmt, gimple_vop (cfun));
!       mark_sym_for_renaming (gimple_vop (cfun));
      }
  
    /* Now create nodes for all the new nodes.  */
    for (new_i = 0; new_i < VEC_length (tree, build_uses); new_i++)
!     last = add_use_op (stmt,
!                      (tree *) VEC_index (tree, build_uses, new_i),
!                      last);
  
    /* Now set the stmt's operands.  */
    gimple_set_use_ops (stmt, new_list.next);
--- 495,512 ----
        && gimple_vuse (stmt) == NULL_TREE)
      {
        gimple_set_vuse (stmt, gimple_vop (cfun));
!       cfun->gimple_df->rename_vops = 1;
!       cfun->gimple_df->ssa_renaming_needed = 1;
      }
  
    /* Now create nodes for all the new nodes.  */
    for (new_i = 0; new_i < VEC_length (tree, build_uses); new_i++)
!     {
!       tree *op = (tree *) VEC_index (tree, build_uses, new_i);
!       if (DECL_P (*op))
!       cfun->gimple_df->ssa_renaming_needed = 1;
!       last = add_use_op (stmt, op, last);
!     }
  
    /* Now set the stmt's operands.  */
    gimple_set_use_ops (stmt, new_list.next);
Index: trunk/gcc/tree-ssanames.c
===================================================================
*** trunk.orig/gcc/tree-ssanames.c      2012-07-31 11:36:00.000000000 +0200
--- trunk/gcc/tree-ssanames.c   2012-07-31 11:36:00.932083758 +0200
*************** init_ssanames (struct function *fn, int
*** 85,91 ****
    VEC_quick_push (tree, SSANAMES (fn), NULL_TREE);
    FREE_SSANAMES (fn) = NULL;
  
!   SYMS_TO_RENAME (fn) = BITMAP_GGC_ALLOC ();
  }
  
  /* Finalize management of SSA_NAMEs.  */
--- 85,92 ----
    VEC_quick_push (tree, SSANAMES (fn), NULL_TREE);
    FREE_SSANAMES (fn) = NULL;
  
!   fn->gimple_df->ssa_renaming_needed = 0;
!   fn->gimple_df->rename_vops = 0;
  }
  
  /* Finalize management of SSA_NAMEs.  */
Index: trunk/gcc/tree-dfa.c
===================================================================
*** trunk.orig/gcc/tree-dfa.c   2012-07-20 14:55:18.000000000 +0200
--- trunk/gcc/tree-dfa.c        2012-07-31 12:19:30.840993382 +0200
*************** make_rename_temp (tree type, const char
*** 174,181 ****
  
    if (gimple_referenced_vars (cfun))
      add_referenced_var (t);
-   if (gimple_in_ssa_p (cfun))
-     mark_sym_for_renaming (t);
  
    return t;
  }
--- 174,179 ----
Index: trunk/gcc/tree-ssa.c
===================================================================
*** trunk.orig/gcc/tree-ssa.c   2012-07-20 12:18:29.000000000 +0200
--- trunk/gcc/tree-ssa.c        2012-07-31 11:46:30.902061935 +0200
*************** struct gimple_opt_pass pass_early_warn_u
*** 1771,1777 ****
     a MEM_REF to a plain or converted symbol.  */
  
  static void
! maybe_rewrite_mem_ref_base (tree *tp)
  {
    tree sym;
  
--- 1771,1777 ----
     a MEM_REF to a plain or converted symbol.  */
  
  static void
! maybe_rewrite_mem_ref_base (tree *tp, bitmap suitable_for_renaming)
  {
    tree sym;
  
*************** maybe_rewrite_mem_ref_base (tree *tp)
*** 1782,1788 ****
        && (sym = TREE_OPERAND (TREE_OPERAND (*tp, 0), 0))
        && DECL_P (sym)
        && !TREE_ADDRESSABLE (sym)
!       && symbol_marked_for_renaming (sym))
      {
        if (TREE_CODE (TREE_TYPE (sym)) == VECTOR_TYPE
          && useless_type_conversion_p (TREE_TYPE (*tp),
--- 1782,1788 ----
        && (sym = TREE_OPERAND (TREE_OPERAND (*tp, 0), 0))
        && DECL_P (sym)
        && !TREE_ADDRESSABLE (sym)
!       && bitmap_bit_p (suitable_for_renaming, DECL_UID (sym)))
      {
        if (TREE_CODE (TREE_TYPE (sym)) == VECTOR_TYPE
          && useless_type_conversion_p (TREE_TYPE (*tp),
*************** non_rewritable_lvalue_p (tree lhs)
*** 1891,1911 ****
     mark the variable VAR for conversion into SSA.  Return true when updating
     stmts is required.  */
  
! static bool
! maybe_optimize_var (tree var, bitmap addresses_taken, bitmap not_reg_needs)
  {
-   bool update_vops = false;
- 
    /* Global Variables, result decls cannot be changed.  */
    if (is_global_var (var)
        || TREE_CODE (var) == RESULT_DECL
        || bitmap_bit_p (addresses_taken, DECL_UID (var)))
!     return false;
! 
!   /* If the variable is not in the list of referenced vars then we
!      do not need to touch it nor can we rename it.  */
!   if (!referenced_var_lookup (cfun, DECL_UID (var)))
!     return false;
  
    if (TREE_ADDRESSABLE (var)
        /* Do not change TREE_ADDRESSABLE if we need to preserve var as
--- 1891,1905 ----
     mark the variable VAR for conversion into SSA.  Return true when updating
     stmts is required.  */
  
! static void
! maybe_optimize_var (tree var, bitmap addresses_taken, bitmap not_reg_needs,
!                   bitmap suitable_for_renaming)
  {
    /* Global Variables, result decls cannot be changed.  */
    if (is_global_var (var)
        || TREE_CODE (var) == RESULT_DECL
        || bitmap_bit_p (addresses_taken, DECL_UID (var)))
!     return;
  
    if (TREE_ADDRESSABLE (var)
        /* Do not change TREE_ADDRESSABLE if we need to preserve var as
*************** maybe_optimize_var (tree var, bitmap add
*** 1918,1925 ****
      {
        TREE_ADDRESSABLE (var) = 0;
        if (is_gimple_reg (var))
!       mark_sym_for_renaming (var);
!       update_vops = true;
        if (dump_file)
        {
          fprintf (dump_file, "No longer having address taken: ");
--- 1912,1918 ----
      {
        TREE_ADDRESSABLE (var) = 0;
        if (is_gimple_reg (var))
!       bitmap_set_bit (suitable_for_renaming, DECL_UID (var));
        if (dump_file)
        {
          fprintf (dump_file, "No longer having address taken: ");
*************** maybe_optimize_var (tree var, bitmap add
*** 1936,1943 ****
        && (TREE_CODE (var) != VAR_DECL || !DECL_HARD_REGISTER (var)))
      {
        DECL_GIMPLE_REG_P (var) = 1;
!       mark_sym_for_renaming (var);
!       update_vops = true;
        if (dump_file)
        {
          fprintf (dump_file, "Now a gimple register: ");
--- 1929,1935 ----
        && (TREE_CODE (var) != VAR_DECL || !DECL_HARD_REGISTER (var)))
      {
        DECL_GIMPLE_REG_P (var) = 1;
!       bitmap_set_bit (suitable_for_renaming, DECL_UID (var));
        if (dump_file)
        {
          fprintf (dump_file, "Now a gimple register: ");
*************** maybe_optimize_var (tree var, bitmap add
*** 1945,1952 ****
          fprintf (dump_file, "\n");
        }
      }
- 
-   return update_vops;
  }
  
  /* Compute TREE_ADDRESSABLE and DECL_GIMPLE_REG_P for local variables.  */
--- 1937,1942 ----
*************** execute_update_addresses_taken (void)
*** 1958,1964 ****
    basic_block bb;
    bitmap addresses_taken = BITMAP_ALLOC (NULL);
    bitmap not_reg_needs = BITMAP_ALLOC (NULL);
!   bool update_vops = false;
    tree var;
    unsigned i;
  
--- 1948,1954 ----
    basic_block bb;
    bitmap addresses_taken = BITMAP_ALLOC (NULL);
    bitmap not_reg_needs = BITMAP_ALLOC (NULL);
!   bitmap suitable_for_renaming = BITMAP_ALLOC (NULL);
    tree var;
    unsigned i;
  
*************** execute_update_addresses_taken (void)
*** 2057,2070 ****
       unused vars from BLOCK trees, which causes code generation differences
       for -g vs. -g0.  */
    for (var = DECL_ARGUMENTS (cfun->decl); var; var = DECL_CHAIN (var))
!     update_vops |= maybe_optimize_var (var, addresses_taken, not_reg_needs);
  
    FOR_EACH_VEC_ELT (tree, cfun->local_decls, i, var)
!     update_vops |= maybe_optimize_var (var, addresses_taken, not_reg_needs);
  
    /* Operand caches need to be recomputed for operands referencing the updated
!      variables.  */
!   if (update_vops)
      {
        FOR_EACH_BB (bb)
        for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi);)
--- 2047,2062 ----
       unused vars from BLOCK trees, which causes code generation differences
       for -g vs. -g0.  */
    for (var = DECL_ARGUMENTS (cfun->decl); var; var = DECL_CHAIN (var))
!     maybe_optimize_var (var, addresses_taken, not_reg_needs,
!                       suitable_for_renaming);
  
    FOR_EACH_VEC_ELT (tree, cfun->local_decls, i, var)
!     maybe_optimize_var (var, addresses_taken, not_reg_needs,
!                       suitable_for_renaming);
  
    /* Operand caches need to be recomputed for operands referencing the updated
!      variables and operands need to be rewritten to expose bare symbols.  */
!   if (!bitmap_empty_p (suitable_for_renaming))
      {
        FOR_EACH_BB (bb)
        for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi);)
*************** execute_update_addresses_taken (void)
*** 2090,2103 ****
                    && (sym = TREE_OPERAND (TREE_OPERAND (lhs, 0), 0))
                    && DECL_P (sym)
                    && !TREE_ADDRESSABLE (sym)
!                   && symbol_marked_for_renaming (sym))
                  lhs = sym;
                else
                  lhs = gimple_assign_lhs (stmt);
  
                /* Rewrite the RHS and make sure the resulting assignment
                   is validly typed.  */
!               maybe_rewrite_mem_ref_base (rhsp);
                rhs = gimple_assign_rhs1 (stmt);
                if (gimple_assign_lhs (stmt) != lhs
                    && !useless_type_conversion_p (TREE_TYPE (lhs),
--- 2082,2095 ----
                    && (sym = TREE_OPERAND (TREE_OPERAND (lhs, 0), 0))
                    && DECL_P (sym)
                    && !TREE_ADDRESSABLE (sym)
!                   && bitmap_bit_p (suitable_for_renaming, DECL_UID (sym)))
                  lhs = sym;
                else
                  lhs = gimple_assign_lhs (stmt);
  
                /* Rewrite the RHS and make sure the resulting assignment
                   is validly typed.  */
!               maybe_rewrite_mem_ref_base (rhsp, suitable_for_renaming);
                rhs = gimple_assign_rhs1 (stmt);
                if (gimple_assign_lhs (stmt) != lhs
                    && !useless_type_conversion_p (TREE_TYPE (lhs),
*************** execute_update_addresses_taken (void)
*** 2112,2118 ****
                   TREE_ADDRESSABLE just remove the stmt.  */
                if (DECL_P (lhs)
                    && TREE_CLOBBER_P (rhs)
!                   && symbol_marked_for_renaming (lhs))
                  {
                    unlink_stmt_vdef (stmt);
                            gsi_remove (&gsi, true);
--- 2104,2110 ----
                   TREE_ADDRESSABLE just remove the stmt.  */
                if (DECL_P (lhs)
                    && TREE_CLOBBER_P (rhs)
!                   && bitmap_bit_p (suitable_for_renaming, DECL_UID (lhs)))
                  {
                    unlink_stmt_vdef (stmt);
                            gsi_remove (&gsi, true);
*************** execute_update_addresses_taken (void)
*** 2133,2139 ****
                for (i = 0; i < gimple_call_num_args (stmt); ++i)
                  {
                    tree *argp = gimple_call_arg_ptr (stmt, i);
!                   maybe_rewrite_mem_ref_base (argp);
                  }
              }
  
--- 2125,2131 ----
                for (i = 0; i < gimple_call_num_args (stmt); ++i)
                  {
                    tree *argp = gimple_call_arg_ptr (stmt, i);
!                   maybe_rewrite_mem_ref_base (argp, suitable_for_renaming);
                  }
              }
  
*************** execute_update_addresses_taken (void)
*** 2143,2154 ****
                for (i = 0; i < gimple_asm_noutputs (stmt); ++i)
                  {
                    tree link = gimple_asm_output_op (stmt, i);
!                   maybe_rewrite_mem_ref_base (&TREE_VALUE (link));
                  }
                for (i = 0; i < gimple_asm_ninputs (stmt); ++i)
                  {
                    tree link = gimple_asm_input_op (stmt, i);
!                   maybe_rewrite_mem_ref_base (&TREE_VALUE (link));
                  }
              }
  
--- 2135,2148 ----
                for (i = 0; i < gimple_asm_noutputs (stmt); ++i)
                  {
                    tree link = gimple_asm_output_op (stmt, i);
!                   maybe_rewrite_mem_ref_base (&TREE_VALUE (link),
!                                               suitable_for_renaming);
                  }
                for (i = 0; i < gimple_asm_ninputs (stmt); ++i)
                  {
                    tree link = gimple_asm_input_op (stmt, i);
!                   maybe_rewrite_mem_ref_base (&TREE_VALUE (link),
!                                               suitable_for_renaming);
                  }
              }
  
*************** execute_update_addresses_taken (void)
*** 2157,2165 ****
              {
                tree *valuep = gimple_debug_bind_get_value_ptr (stmt);
                tree decl;
!               maybe_rewrite_mem_ref_base (valuep);
                decl = non_rewritable_mem_ref_base (*valuep);
!               if (decl && symbol_marked_for_renaming (decl))
                  gimple_debug_bind_reset_value (stmt);
              }
  
--- 2151,2160 ----
              {
                tree *valuep = gimple_debug_bind_get_value_ptr (stmt);
                tree decl;
!               maybe_rewrite_mem_ref_base (valuep, suitable_for_renaming);
                decl = non_rewritable_mem_ref_base (*valuep);
!               if (decl
!                   && bitmap_bit_p (suitable_for_renaming, DECL_UID (decl)))
                  gimple_debug_bind_reset_value (stmt);
              }
  
*************** execute_update_addresses_taken (void)
*** 2179,2184 ****
--- 2174,2180 ----
  
    BITMAP_FREE (not_reg_needs);
    BITMAP_FREE (addresses_taken);
+   BITMAP_FREE (suitable_for_renaming);
    timevar_pop (TV_ADDRESS_TAKEN);
  }
  
Index: trunk/gcc/cgraphunit.c
===================================================================
*** trunk.orig/gcc/cgraphunit.c 2012-07-27 14:06:30.000000000 +0200
--- trunk/gcc/cgraphunit.c      2012-07-31 12:52:38.626924546 +0200
*************** assemble_thunk (struct cgraph_node *node
*** 1455,1467 ****
        else
          VEC_quick_push (tree, vargs, a);
        add_referenced_var (a);
-       if (is_gimple_reg (a))
-       mark_sym_for_renaming (a);
        for (i = 1, arg = DECL_CHAIN (a); i < nargs; i++, arg = DECL_CHAIN 
(arg))
        {
          add_referenced_var (arg);
-         if (is_gimple_reg (arg))
-           mark_sym_for_renaming (arg);
          VEC_quick_push (tree, vargs, arg);
        }
        call = gimple_build_call_vec (build_fold_addr_expr_loc (0, alias), 
vargs);
--- 1455,1463 ----
Index: trunk/gcc/gimplify.c
===================================================================
*** trunk.orig/gcc/gimplify.c   2012-07-26 10:46:42.000000000 +0200
--- trunk/gcc/gimplify.c        2012-07-31 12:53:38.403922505 +0200
*************** gimple_regimplify_operands (gimple stmt,
*** 8527,8548 ****
        add_referenced_var (t);
  
    if (!gimple_seq_empty_p (pre))
!     {
!       if (gimple_in_ssa_p (cfun))
!       {
!         gimple_stmt_iterator i;
! 
!         for (i = gsi_start (pre); !gsi_end_p (i); gsi_next (&i))
!           {
!             tree lhs = gimple_get_lhs (gsi_stmt (i));
!             if (lhs
!                 && TREE_CODE (lhs) != SSA_NAME
!                 && is_gimple_reg (lhs))
!               mark_sym_for_renaming (lhs);
!           }
!       }
!       gsi_insert_seq_before (gsi_p, pre, GSI_SAME_STMT);
!     }
    if (post_stmt)
      gsi_insert_after (gsi_p, post_stmt, GSI_NEW_STMT);
  
--- 8527,8533 ----
        add_referenced_var (t);
  
    if (!gimple_seq_empty_p (pre))
!     gsi_insert_seq_before (gsi_p, pre, GSI_SAME_STMT);
    if (post_stmt)
      gsi_insert_after (gsi_p, post_stmt, GSI_NEW_STMT);
  
*************** force_gimple_operand_1 (tree expr, gimpl
*** 8593,8613 ****
      for (t = gimplify_ctxp->temps; t ; t = DECL_CHAIN (t))
        add_referenced_var (t);
  
-   if (!gimple_seq_empty_p (*stmts)
-       && gimplify_ctxp->into_ssa)
-     {
-       gimple_stmt_iterator i;
- 
-       for (i = gsi_start (*stmts); !gsi_end_p (i); gsi_next (&i))
-       {
-         tree lhs = gimple_get_lhs (gsi_stmt (i));
-         if (lhs
-             && TREE_CODE (lhs) != SSA_NAME
-             && is_gimple_reg (lhs))
-           mark_sym_for_renaming (lhs);
-       }
-     }
- 
    pop_gimplify_context (NULL);
  
    return expr;
--- 8578,8583 ----
Index: trunk/gcc/ipa-prop.c
===================================================================
*** trunk.orig/gcc/ipa-prop.c   2012-07-16 14:10:04.000000000 +0200
--- trunk/gcc/ipa-prop.c        2012-07-31 12:54:03.348921636 +0200
*************** ipa_modify_formal_parameters (tree fndec
*** 2356,2362 ****
          layout_decl (new_parm, 0);
  
          add_referenced_var (new_parm);
-         mark_sym_for_renaming (new_parm);
          adj->base = parm;
          adj->reduction = new_parm;
  
--- 2356,2361 ----
Index: trunk/gcc/matrix-reorg.c
===================================================================
*** trunk.orig/gcc/matrix-reorg.c       2012-07-16 14:10:02.000000000 +0200
--- trunk/gcc/matrix-reorg.c    2012-07-31 12:57:49.334913807 +0200
*************** transform_access_sites (void **slot, voi
*** 1815,1822 ****
              gimple stmt = acc_info->stmt;
              tree lhs;
  
-             FOR_EACH_SSA_TREE_OPERAND (def, stmt, iter, SSA_OP_DEF)
-               mark_sym_for_renaming (SSA_NAME_VAR (def));
              gsi = gsi_for_stmt (stmt);
              gcc_assert (is_gimple_assign (acc_info->stmt));
              lhs = gimple_assign_lhs (acc_info->stmt);
--- 1815,1820 ----
Index: trunk/gcc/tree-inline.c
===================================================================
*** trunk.orig/gcc/tree-inline.c        2012-07-24 10:35:57.000000000 +0200
--- trunk/gcc/tree-inline.c     2012-07-31 12:59:55.552909446 +0200
*************** declare_return_variable (copy_body_data
*** 2943,2953 ****
        TREE_ADDRESSABLE (var) = 1;
        var = build_fold_addr_expr (var);
      }
-   else if (gimple_in_ssa_p (cfun)
-          && is_gimple_reg (var))
-     /* ???  Re-org id->retval and its special handling so that we can
-        record an SSA name directly and not need to invoke the SSA renamer.  */
-     mark_sym_for_renaming (var);
  
   done:
    /* Register the VAR_DECL as the equivalent for the RESULT_DECL; that
--- 2943,2948 ----
Index: trunk/gcc/tree-parloops.c
===================================================================
*** trunk.orig/gcc/tree-parloops.c      2012-07-16 14:10:02.000000000 +0200
--- trunk/gcc/tree-parloops.c   2012-07-31 13:12:52.880882552 +0200
*************** separate_decls_in_region_stmt (edge entr
*** 861,868 ****
    tree name, copy;
    bool copy_name_p;
  
-   mark_virtual_ops_for_renaming (stmt);
- 
    FOR_EACH_PHI_OR_STMT_DEF (def, stmt, oi, SSA_OP_DEF)
    {
      name = DEF_FROM_PTR (def);
--- 861,866 ----
*************** create_stores_for_reduction (void **slot
*** 1182,1188 ****
    gsi = gsi_last_bb (clsn_data->store_bb);
    t = build3 (COMPONENT_REF, type, clsn_data->store, red->field, NULL_TREE);
    stmt = gimple_build_assign (t, red->initial_value);
-   mark_virtual_ops_for_renaming (stmt);
    gsi_insert_after (&gsi, stmt, GSI_NEW_STMT);
  
    return 1;
--- 1180,1185 ----
*************** create_loads_and_stores_for_name (void *
*** 1206,1212 ****
    gsi = gsi_last_bb (clsn_data->store_bb);
    t = build3 (COMPONENT_REF, type, clsn_data->store, elt->field, NULL_TREE);
    stmt = gimple_build_assign (t, ssa_name (elt->version));
-   mark_virtual_ops_for_renaming (stmt);
    gsi_insert_after (&gsi, stmt, GSI_NEW_STMT);
  
    gsi = gsi_last_bb (clsn_data->load_bb);
--- 1203,1208 ----
Index: trunk/gcc/tree-predcom.c
===================================================================
*** trunk.orig/gcc/tree-predcom.c       2012-07-16 14:10:03.000000000 +0200
--- trunk/gcc/tree-predcom.c    2012-07-31 13:13:05.602882084 +0200
*************** get_init_expr (chain_p chain, unsigned i
*** 1442,1471 ****
      return VEC_index (tree, chain->inits, index);
  }
  
- /* Marks all virtual operands of statement STMT for renaming.  */
- 
- void
- mark_virtual_ops_for_renaming (gimple stmt)
- {
-   tree var;
- 
-   if (gimple_code (stmt) == GIMPLE_PHI)
-     {
-       var = PHI_RESULT (stmt);
-       if (is_gimple_reg (var))
-       return;
- 
-       if (TREE_CODE (var) == SSA_NAME)
-       var = SSA_NAME_VAR (var);
-       mark_sym_for_renaming (var);
-       return;
-     }
- 
-   update_stmt (stmt);
-   if (gimple_vuse (stmt))
-     mark_sym_for_renaming (gimple_vop (cfun));
- }
- 
  /* Returns a new temporary variable used for the I-th variable carrying
     value of REF.  The variable's uid is marked in TMP_VARS.  */
  
--- 1442,1447 ----
*************** initialize_root_vars_lm (struct loop *lo
*** 1602,1608 ****
    else
      {
        gimple init_stmt = gimple_build_assign (var, init);
-       mark_virtual_ops_for_renaming (init_stmt);
        gsi_insert_on_edge_immediate (entry, init_stmt);
      }
  }
--- 1578,1583 ----
*************** execute_load_motion (struct loop *loop,
*** 1636,1642 ****
    FOR_EACH_VEC_ELT (dref, chain->refs, i, a)
      {
        bool is_read = DR_IS_READ (a->ref);
-       mark_virtual_ops_for_renaming (a->stmt);
  
        if (DR_IS_WRITE (a->ref))
        {
--- 1611,1616 ----
*************** remove_stmt (gimple stmt)
*** 1732,1738 ****
        next = single_nonlooparound_use (name);
        reset_debug_uses (stmt);
  
!       mark_virtual_ops_for_renaming (stmt);
        gsi_remove (&bsi, true);
        release_defs (stmt);
  
--- 1706,1712 ----
        next = single_nonlooparound_use (name);
        reset_debug_uses (stmt);
  
!       unlink_stmt_vdef (stmt);
        gsi_remove (&bsi, true);
        release_defs (stmt);
  
*************** execute_pred_commoning_chain (struct loo
*** 1753,1759 ****
                             bitmap tmp_vars)
  {
    unsigned i;
!   dref a, root;
    tree var;
  
    if (chain->combined)
--- 1727,1733 ----
                             bitmap tmp_vars)
  {
    unsigned i;
!   dref a;
    tree var;
  
    if (chain->combined)
*************** execute_pred_commoning_chain (struct loo
*** 1768,1780 ****
        /* For non-combined chains, set up the variables that hold its value,
         and replace the uses of the original references by these
         variables.  */
-       root = get_chain_root (chain);
-       mark_virtual_ops_for_renaming (root->stmt);
- 
        initialize_root (loop, chain, tmp_vars);
        for (i = 1; VEC_iterate (dref, chain->refs, i, a); i++)
        {
-         mark_virtual_ops_for_renaming (a->stmt);
          var = VEC_index (tree, chain->vars, chain->length - a->distance);
          replace_ref_with (a->stmt, var, false, false);
        }
--- 1742,1750 ----
Index: trunk/gcc/tree-sra.c
===================================================================
*** trunk.orig/gcc/tree-sra.c   2012-07-20 12:16:12.000000000 +0200
--- trunk/gcc/tree-sra.c        2012-07-31 13:18:31.602870800 +0200
*************** sort_and_splice_var_accesses (tree var)
*** 1826,1840 ****
     ACCESS->replacement.  */
  
  static tree
! create_access_replacement (struct access *access, bool rename)
  {
    tree repl;
  
    repl = create_tmp_var (access->type, "SR");
    add_referenced_var (repl);
-   if (!access->grp_partial_lhs
-       && rename)
-     mark_sym_for_renaming (repl);
  
    if (TREE_CODE (access->type) == COMPLEX_TYPE
        || TREE_CODE (access->type) == VECTOR_TYPE)
--- 1826,1837 ----
     ACCESS->replacement.  */
  
  static tree
! create_access_replacement (struct access *access)
  {
    tree repl;
  
    repl = create_tmp_var (access->type, "SR");
    add_referenced_var (repl);
  
    if (TREE_CODE (access->type) == COMPLEX_TYPE
        || TREE_CODE (access->type) == VECTOR_TYPE)
*************** create_access_replacement (struct access
*** 1915,1937 ****
  static inline tree
  get_access_replacement (struct access *access)
  {
-   gcc_assert (access->grp_to_be_replaced);
- 
-   if (!access->replacement_decl)
-     access->replacement_decl = create_access_replacement (access, true);
-   return access->replacement_decl;
- }
- 
- /* Return ACCESS scalar replacement, create it if it does not exist yet but do
-    not mark it for renaming.  */
- 
- static inline tree
- get_unrenamed_access_replacement (struct access *access)
- {
-   gcc_assert (!access->grp_to_be_replaced);
- 
    if (!access->replacement_decl)
!     access->replacement_decl = create_access_replacement (access, false);
    return access->replacement_decl;
  }
  
--- 1912,1919 ----
  static inline tree
  get_access_replacement (struct access *access)
  {
    if (!access->replacement_decl)
!     access->replacement_decl = create_access_replacement (access);
    return access->replacement_decl;
  }
  
*************** get_repl_default_def_ssa_name (struct ac
*** 2830,2836 ****
  {
    tree repl, decl;
  
!   decl = get_unrenamed_access_replacement (racc);
  
    repl = gimple_default_def (cfun, decl);
    if (!repl)
--- 2812,2818 ----
  {
    tree repl, decl;
  
!   decl = get_access_replacement (racc);
  
    repl = gimple_default_def (cfun, decl);
    if (!repl)
Index: trunk/gcc/tree-ssa-loop-im.c
===================================================================
*** trunk.orig/gcc/tree-ssa-loop-im.c   2012-07-16 14:09:59.000000000 +0200
--- trunk/gcc/tree-ssa-loop-im.c        2012-07-31 13:29:15.785848490 +0200
*************** move_computations_stmt (struct dom_walk_
*** 1291,1296 ****
--- 1291,1298 ----
  
    for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); )
      {
+       edge e;
+ 
        stmt = gsi_stmt (bsi);
  
        lim_data = get_lim_data (stmt);
*************** move_computations_stmt (struct dom_walk_
*** 1323,1331 ****
                   cost, level->num);
        }
  
!       mark_virtual_ops_for_renaming (stmt);
        gsi_remove (&bsi, false);
!       gsi_insert_on_edge (loop_preheader_edge (level), stmt);
      }
  }
  
--- 1325,1350 ----
                   cost, level->num);
        }
  
!       e = loop_preheader_edge (level);
!       gcc_assert (!gimple_vdef (stmt));
!       if (gimple_vuse (stmt))
!       {
!         /* The new VUSE is the one from the virtual PHI in the loop
!            header or the one already present.  */
!         gimple_stmt_iterator gsi2;
!         for (gsi2 = gsi_start_phis (e->dest);
!              !gsi_end_p (gsi2); gsi_next (&gsi2))
!           {
!             gimple phi = gsi_stmt (gsi2);
!             if (!is_gimple_reg (gimple_phi_result (phi)))
!               {
!                 gimple_set_vuse (stmt, PHI_ARG_DEF_FROM_EDGE (phi, e));
!                 break;
!               }
!           }
!       }
        gsi_remove (&bsi, false);
!       gsi_insert_on_edge (e, stmt);
      }
  }
  
*************** mem_refs_may_alias_p (tree mem1, tree me
*** 1783,1789 ****
  static void
  rewrite_mem_ref_loc (mem_ref_loc_p loc, tree tmp_var)
  {
-   mark_virtual_ops_for_renaming (loc->stmt);
    *loc->ref = tmp_var;
    update_stmt (loc->stmt);
  }
--- 1802,1807 ----
Index: trunk/gcc/tree-ssa-loop-prefetch.c
===================================================================
*** trunk.orig/gcc/tree-ssa-loop-prefetch.c     2012-07-16 14:10:04.000000000 
+0200
--- trunk/gcc/tree-ssa-loop-prefetch.c  2012-07-31 13:11:43.301884914 +0200
*************** emit_mfence_after_loop (struct loop *loo
*** 1204,1210 ****
        bsi = gsi_after_labels (exit->dest);
  
        gsi_insert_before (&bsi, call, GSI_NEW_STMT);
-       mark_virtual_ops_for_renaming (call);
      }
  
    VEC_free (edge, heap, exits);
--- 1204,1209 ----

Reply via email to