This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
This is off-topic split from the PRE conversion patch. It allows us to free SSA-names again, it fixes gcc.dg/torture/pr36373-6.c, it makes dumps closer to trunk which fixes all of vrp* at least. Bootstrapped and "tested" on x86_64-unknown-linux-gnu (I don't have a baseline handy for tuples - please somebody compare against one and check in this patch). (testsuite summary attached) Thanks, Richard. 2008-07-10 Richard Guenther <rguenther@suse.de> * gimple.h (gimple_assign_ssa_name_copy_p): Declare. (gimple_has_lhs): New function. * gimple.c (gimple_assign_ssa_name_copy_p): New function. * tree-ssa-copy.c (propagate_tree_value_into_stmt): Remove redundant gimple_set_location call. * gimple-iterator.c (gsi_remove): Do not free stmt operands. * tree-ssa-structalias.c (find_func_aliases): Correctly let all things with pointers escape. * tree-pass.h (TDF_RHS_ONLY): New flag. * diagnostic.h (print_gimple_expr): Declare. * gimple-pretty-print.c (print_gimple_expr): New function. (dump_gimple_assign): Dump the RHS as expression if TDF_RHS_ONLY. (dump_gimple_call): Likewise. (dump_gimple_cond): Likewise. * tree-ssa-propagate.c (fold_predicate_in): Use print_gimple_expr. * tree-ssa-sccvn.c (visit_use): Use gimple_has_lhs. Use print_gimple_expr. Handle tcc_expression correctly. * testsuite/gcc.dg/tree-ssa/pr25485.c: Revert to trunk version. Index: gimple-tuples-branch/gcc/gimple.c =================================================================== *** gimple-tuples-branch.orig/gcc/gimple.c 2008-07-10 18:00:13.000000000 +0200 --- gimple-tuples-branch/gcc/gimple.c 2008-07-10 18:00:18.000000000 +0200 *************** gimple_assign_copy_p (gimple gs) *** 1838,1843 **** --- 1838,1857 ---- && is_gimple_val (gimple_op (gs, 1)); } + + /* Return true if GS is a SSA_NAME copy assignment. */ + + bool + gimple_assign_ssa_name_copy_p (gimple gs) + { + return (gimple_code (gs) == GIMPLE_ASSIGN + && (get_gimple_rhs_class (gimple_assign_rhs_code (gs)) + == GIMPLE_SINGLE_RHS) + && TREE_CODE (gimple_assign_lhs (gs)) == SSA_NAME + && TREE_CODE (gimple_assign_rhs1 (gs)) == SSA_NAME); + } + + /* Return true if GS is an assignment with a singleton RHS, i.e., there is no operator associated with the assignment itself. Unlike gimple_assign_copy_p, this predicate returns true for Index: gimple-tuples-branch/gcc/gimple.h =================================================================== *** gimple-tuples-branch.orig/gcc/gimple.h 2008-07-10 18:00:13.000000000 +0200 --- gimple-tuples-branch/gcc/gimple.h 2008-07-10 18:00:18.000000000 +0200 *************** void gimple_seq_add_seq (gimple_seq *, g *** 822,827 **** --- 822,828 ---- gimple_seq gimple_seq_copy (gimple_seq); int gimple_call_flags (const_gimple); bool gimple_assign_copy_p (gimple); + bool gimple_assign_ssa_name_copy_p (gimple); bool gimple_assign_single_p (gimple); bool gimple_assign_unary_nop_p (gimple); void gimple_set_bb (gimple, struct basic_block_def *); *************** gimple_call_copy_flags (gimple dest_call *** 2022,2027 **** --- 2023,2040 ---- } + /* Returns true if this is a GIMPLE_ASSIGN or a GIMPLE_CALL with a + non-NULL lhs. */ + + static inline bool + gimple_has_lhs (gimple stmt) + { + return (is_gimple_assign (stmt) + || (is_gimple_call (stmt) + && gimple_call_lhs (stmt) != NULL_TREE)); + } + + /* Return the code of the predicate computed by conditional statement GS. */ static inline enum tree_code Index: gimple-tuples-branch/gcc/tree-ssa-sccvn.c =================================================================== *** gimple-tuples-branch.orig/gcc/tree-ssa-sccvn.c 2008-07-10 18:00:13.000000000 +0200 --- gimple-tuples-branch/gcc/tree-ssa-sccvn.c 2008-07-10 18:02:59.000000000 +0200 *************** visit_use (tree use) *** 2085,2093 **** { if (gimple_code (stmt) == GIMPLE_PHI) changed = visit_phi (stmt); ! else if ((gimple_code (stmt) != GIMPLE_ASSIGN ! && (gimple_code (stmt) != GIMPLE_CALL ! || gimple_call_lhs (stmt) == NULL_TREE)) || gimple_has_volatile_ops (stmt) || stmt_could_throw_p (stmt)) changed = defs_to_varying (stmt); --- 2085,2091 ---- { if (gimple_code (stmt) == GIMPLE_PHI) changed = visit_phi (stmt); ! else if (!gimple_has_lhs (stmt) || gimple_has_volatile_ops (stmt) || stmt_could_throw_p (stmt)) changed = defs_to_varying (stmt); *************** visit_use (tree use) *** 2110,2117 **** { if (dump_file && (dump_flags & TDF_DETAILS)) { ! fprintf (dump_file, "RHS of "); ! print_gimple_stmt (dump_file, stmt, 0, 0); fprintf (dump_file, " simplified to "); print_generic_expr (dump_file, simplified, 0); if (TREE_CODE (lhs) == SSA_NAME) --- 2108,2115 ---- { if (dump_file && (dump_flags & TDF_DETAILS)) { ! fprintf (dump_file, "RHS "); ! print_gimple_expr (dump_file, stmt, 0, 0); fprintf (dump_file, " simplified to "); print_generic_expr (dump_file, simplified, 0); if (TREE_CODE (lhs) == SSA_NAME) *************** visit_use (tree use) *** 2211,2218 **** break; case tcc_expression: if (gimple_assign_rhs_code (stmt) == ADDR_EXPR) ! changed = visit_unary_op (lhs, stmt); ! break; default: changed = defs_to_varying (stmt); } --- 2209,2219 ---- break; case tcc_expression: if (gimple_assign_rhs_code (stmt) == ADDR_EXPR) ! { ! changed = visit_unary_op (lhs, stmt); ! break; ! } ! /* Fallthrough. */ default: changed = defs_to_varying (stmt); } Index: gimple-tuples-branch/gcc/tree-ssa-copy.c =================================================================== *** gimple-tuples-branch.orig/gcc/tree-ssa-copy.c 2008-07-10 18:00:13.000000000 +0200 --- gimple-tuples-branch/gcc/tree-ssa-copy.c 2008-07-10 18:00:18.000000000 +0200 *************** propagate_tree_value_into_stmt (gimple_s *** 467,473 **** new_stmt = gimple_build_assign (gimple_call_lhs (stmt), expr); copy_virtual_operands (new_stmt, stmt); move_ssa_defining_stmt_for_defs (new_stmt, stmt); - gimple_set_location (new_stmt, gimple_location (stmt)); gsi_replace (gsi, new_stmt, false); } else if (gimple_code (stmt) == GIMPLE_SWITCH) --- 467,472 ---- Index: gimple-tuples-branch/gcc/gimple-pretty-print.c =================================================================== *** gimple-tuples-branch.orig/gcc/gimple-pretty-print.c 2008-07-10 18:00:13.000000000 +0200 --- gimple-tuples-branch/gcc/gimple-pretty-print.c 2008-07-10 18:02:22.000000000 +0200 *************** print_gimple_stmt (FILE *file, gimple g, *** 101,106 **** --- 101,119 ---- } + /* Dump GIMPLE statement G to FILE using SPC indentantion spaces and + FLAGS as in dump_gimple_stmt. Print only the right-hand side + of the statement. */ + + void + print_gimple_expr (FILE *file, gimple g, int spc, int flags) + { + flags |= TDF_RHS_ONLY; + maybe_init_pretty_print (file); + dump_gimple_stmt (&buffer, g, spc, flags); + } + + /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentantion spaces and FLAGS as in dump_gimple_stmt. */ *************** dump_gimple_assign (pretty_printer *buff *** 357,373 **** } else { ! dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false); ! pp_space (buffer); ! pp_character (buffer, '='); ! if (gimple_assign_nontemporal_move_p (gs)) ! pp_string (buffer, "{nt}"); ! if (gimple_has_volatile_ops (gs)) ! pp_string (buffer, "{v}"); ! pp_space (buffer); if (gimple_num_ops (gs) == 2) dump_unary_rhs (buffer, gs, spc, flags); --- 370,389 ---- } else { ! if (!(flags & TDF_RHS_ONLY)) ! { ! dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false); ! pp_space (buffer); ! pp_character (buffer, '='); ! if (gimple_assign_nontemporal_move_p (gs)) ! pp_string (buffer, "{nt}"); ! if (gimple_has_volatile_ops (gs)) ! pp_string (buffer, "{v}"); ! pp_space (buffer); ! } if (gimple_num_ops (gs) == 2) dump_unary_rhs (buffer, gs, spc, flags); *************** dump_gimple_assign (pretty_printer *buff *** 375,381 **** dump_binary_rhs (buffer, gs, spc, flags); else gcc_unreachable (); ! pp_semicolon(buffer); } } --- 391,398 ---- dump_binary_rhs (buffer, gs, spc, flags); else gcc_unreachable (); ! if (!(flags & TDF_RHS_ONLY)) ! pp_semicolon(buffer); } } *************** dump_gimple_call (pretty_printer *buffer *** 453,459 **** } else { ! if (lhs) { dump_generic_node (buffer, lhs, spc, flags, false); pp_string (buffer, " ="); --- 470,476 ---- } else { ! if (lhs && !(flags & TDF_RHS_ONLY)) { dump_generic_node (buffer, lhs, spc, flags, false); pp_string (buffer, " ="); *************** dump_gimple_call (pretty_printer *buffer *** 467,473 **** pp_string (buffer, " ("); dump_gimple_call_args (buffer, gs, flags); pp_string (buffer, ")"); ! pp_semicolon (buffer); } if (gimple_call_chain (gs)) --- 484,491 ---- pp_string (buffer, " ("); dump_gimple_call_args (buffer, gs, flags); pp_string (buffer, ")"); ! if (!(flags & TDF_RHS_ONLY)) ! pp_semicolon (buffer); } if (gimple_call_chain (gs)) *************** dump_gimple_cond (pretty_printer *buffer *** 533,558 **** gimple_cond_true_label (gs), gimple_cond_false_label (gs)); else { ! pp_string (buffer, "if ("); dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false); pp_space (buffer); pp_string (buffer, op_symbol_code (gimple_cond_code (gs))); pp_space (buffer); dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false); ! pp_string (buffer, ")"); ! ! if (gimple_cond_true_label (gs)) ! { ! pp_string (buffer, " goto "); ! dump_generic_node (buffer, gimple_cond_true_label (gs), spc, flags, ! false); ! } ! if (gimple_cond_false_label (gs)) ! { ! pp_string (buffer, " else goto "); ! dump_generic_node (buffer, gimple_cond_false_label (gs), spc, flags, ! false); ! } } } --- 551,580 ---- gimple_cond_true_label (gs), gimple_cond_false_label (gs)); else { ! if (!(flags & TDF_RHS_ONLY)) ! pp_string (buffer, "if ("); dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false); pp_space (buffer); pp_string (buffer, op_symbol_code (gimple_cond_code (gs))); pp_space (buffer); dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false); ! if (!(flags & TDF_RHS_ONLY)) ! { ! pp_string (buffer, ")"); ! ! if (gimple_cond_true_label (gs)) ! { ! pp_string (buffer, " goto "); ! dump_generic_node (buffer, gimple_cond_true_label (gs), ! spc, flags, false); ! } ! if (gimple_cond_false_label (gs)) ! { ! pp_string (buffer, " else goto "); ! dump_generic_node (buffer, gimple_cond_false_label (gs), ! spc, flags, false); ! } ! } } } Index: gimple-tuples-branch/gcc/testsuite/gcc.dg/tree-ssa/pr25485.c =================================================================== *** gimple-tuples-branch.orig/gcc/testsuite/gcc.dg/tree-ssa/pr25485.c 2008-07-10 18:00:13.000000000 +0200 --- gimple-tuples-branch/gcc/testsuite/gcc.dg/tree-ssa/pr25485.c 2008-07-10 18:00:18.000000000 +0200 *************** foo (int a, int b) *** 13,17 **** return 31; } ! /* { dg-final { scan-tree-dump-times "Folding predicate in if " 1 "vrp1"} } */ /* { dg-final { cleanup-tree-dump "vrp1" } } */ --- 13,17 ---- return 31; } ! /* { dg-final { scan-tree-dump-times "if" 1 "vrp1"} } */ /* { dg-final { cleanup-tree-dump "vrp1" } } */ Index: gimple-tuples-branch/gcc/tree-pass.h =================================================================== *** gimple-tuples-branch.orig/gcc/tree-pass.h 2008-07-10 18:00:13.000000000 +0200 --- gimple-tuples-branch/gcc/tree-pass.h 2008-07-10 18:00:18.000000000 +0200 *************** enum tree_dump_index *** 72,78 **** #define TDF_DIAGNOSTIC (1 << 15) /* A dump to be put in a diagnostic message. */ #define TDF_VERBOSE (1 << 16) /* A dump that uses the full tree ! dumper to print stmts. */ extern char *get_dump_file_name (enum tree_dump_index); extern int dump_enabled_p (enum tree_dump_index); --- 72,80 ---- #define TDF_DIAGNOSTIC (1 << 15) /* A dump to be put in a diagnostic message. */ #define TDF_VERBOSE (1 << 16) /* A dump that uses the full tree ! dumper to print stmts. */ ! #define TDF_RHS_ONLY (1 << 17) /* a flag to only print the RHS of ! a gimple stmt. */ extern char *get_dump_file_name (enum tree_dump_index); extern int dump_enabled_p (enum tree_dump_index); Index: gimple-tuples-branch/gcc/gimple-iterator.c =================================================================== *** gimple-tuples-branch.orig/gcc/gimple-iterator.c 2008-07-10 18:00:13.000000000 +0200 --- gimple-tuples-branch/gcc/gimple-iterator.c 2008-07-10 18:00:18.000000000 +0200 *************** gsi_remove (gimple_stmt_iterator *i, boo *** 486,492 **** if (remove_permanently) { - free_stmt_operands (stmt); remove_stmt_from_eh_region (stmt); gimple_remove_stmt_histograms (cfun, stmt); } --- 486,491 ---- Index: gimple-tuples-branch/gcc/tree-ssa-propagate.c =================================================================== *** gimple-tuples-branch.orig/gcc/tree-ssa-propagate.c 2008-07-10 18:00:13.000000000 +0200 --- gimple-tuples-branch/gcc/tree-ssa-propagate.c 2008-07-10 18:02:42.000000000 +0200 *************** fold_predicate_in (gimple_stmt_iterator *** 1197,1204 **** if (dump_file) { ! fprintf (dump_file, "Folding predicate in "); ! print_gimple_stmt (dump_file, stmt, 0, 0); fprintf (dump_file, " to "); print_generic_expr (dump_file, val, 0); fprintf (dump_file, "\n"); --- 1197,1204 ---- if (dump_file) { ! fprintf (dump_file, "Folding predicate "); ! print_gimple_expr (dump_file, stmt, 0, 0); fprintf (dump_file, " to "); print_generic_expr (dump_file, val, 0); fprintf (dump_file, "\n"); Index: gimple-tuples-branch/gcc/tree-ssa-structalias.c =================================================================== *** gimple-tuples-branch.orig/gcc/tree-ssa-structalias.c 2008-07-10 18:00:13.000000000 +0200 --- gimple-tuples-branch/gcc/tree-ssa-structalias.c 2008-07-10 18:00:18.000000000 +0200 *************** find_func_aliases (gimple origt) *** 3921,3927 **** else if (get_gimple_rhs_class (gimple_assign_rhs_code (t)) == GIMPLE_SINGLE_RHS) { ! if (POINTER_TYPE_P (TREE_TYPE (gimple_assign_rhs1 (t)))) make_escape_constraint (gimple_assign_rhs1 (t)); } /* FIXME tuples --- 3921,3927 ---- else if (get_gimple_rhs_class (gimple_assign_rhs_code (t)) == GIMPLE_SINGLE_RHS) { ! if (could_have_pointers (gimple_assign_rhs1 (t))) make_escape_constraint (gimple_assign_rhs1 (t)); } /* FIXME tuples Index: gimple-tuples-branch/gcc/diagnostic.h =================================================================== *** gimple-tuples-branch.orig/gcc/diagnostic.h 2008-07-10 15:03:29.000000000 +0200 --- gimple-tuples-branch/gcc/diagnostic.h 2008-07-10 18:01:10.000000000 +0200 *************** extern void debug_gimple_stmt (gimple); *** 232,237 **** --- 232,238 ---- extern void debug_gimple_seq (gimple_seq); extern void print_gimple_seq (FILE *, gimple_seq, int, int); extern void print_gimple_stmt (FILE *, gimple, int, int); + extern void print_gimple_expr (FILE *, gimple, int, int); extern void dump_gimple_stmt (pretty_printer *, gimple, int, int); #endif /* ! GCC_DIAGNOSTIC_H */
Attachment:
sum
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |