The testcase in PR56294 shows that we may not depend on the order symbols are registered for renaming for inserting new PHI nodes for them. Instead we should always insert them in order of their symbol UID. This is a regression from the referenced_vars removal series as that introduced the vec of to-be renamed symbols.
Bootstrap and regtest with -fno-ipa-sra running on x86_64-unknown-linux-gnu. Diego: we have vec.qsort (), but why does that insist on that awful const void * argument interface ... some trivial template forwarding (or use of std::qsort?) should be able to fix that. Richard. 2013-03-06 Richard Biener <rguent...@suse.de> PR middle-end/56294 * tree-into-ssa.c (insert_phi_nodes_for): Add dumping. (insert_updated_phi_nodes_compare_uids): New function. (update_ssa): Sort symbols_to_rename after UID before traversing it to insert PHI nodes. Index: gcc/tree-into-ssa.c =================================================================== *** gcc/tree-into-ssa.c (revision 196487) --- gcc/tree-into-ssa.c (working copy) *************** insert_phi_nodes_for (tree var, bitmap p *** 969,974 **** --- 969,980 ---- if (update_p) mark_block_for_update (bb); + if (dump_file && (dump_flags & TDF_DETAILS)) + { + fprintf (dump_file, "creating PHI node in block #%d for ", bb_index); + print_generic_expr (dump_file, var, TDF_SLIM); + fprintf (dump_file, "\n"); + } phi = NULL; if (TREE_CODE (var) == SSA_NAME) *************** insert_updated_phi_nodes_for (tree var, *** 3040,3045 **** --- 3046,3062 ---- BITMAP_FREE (idf); } + /* Sort symbols_to_rename after their DECL_UID. */ + + static int + insert_updated_phi_nodes_compare_uids (const void *a, const void *b) + { + const_tree syma = *(const_tree *)a; + const_tree symb = *(const_tree *)b; + if (DECL_UID (syma) == DECL_UID (symb)) + return 0; + return DECL_UID (syma) < DECL_UID (symb) ? -1 : 1; + } /* 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: *************** update_ssa (unsigned update_flags) *** 3250,3255 **** --- 3267,3273 ---- sbitmap_free (tmp); } + symbols_to_rename.qsort (insert_updated_phi_nodes_compare_uids); FOR_EACH_VEC_ELT (symbols_to_rename, i, sym) insert_updated_phi_nodes_for (sym, dfs, blocks_to_update, update_flags);