Index: tree-cfg.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/tree-cfg.c,v retrieving revision 2.136 diff -c -3 -p -r2.136 tree-cfg.c *** tree-cfg.c 13 Dec 2004 16:06:23 -0000 2.136 --- tree-cfg.c 15 Dec 2004 01:01:15 -0000 *************** dump_function_to_file (tree fn, FILE *fi *** 4865,4873 **** if (any_var && n_basic_blocks) fprintf (file, "\n"); FOR_EACH_BB (bb) dump_generic_bb (file, bb, 2, flags); ! fprintf (file, "}\n"); check_bb_profile (EXIT_BLOCK_PTR, file); } --- 4920,4938 ---- if (any_var && n_basic_blocks) fprintf (file, "\n"); + if ((flags & TDF_NOTEMP) + && ssa_names + && num_ssa_names > 0) + compute_immediate_uses (TDFA_USE_OPS, NULL); + FOR_EACH_BB (bb) dump_generic_bb (file, bb, 2, flags); ! ! if ((flags & TDF_NOTEMP) ! && ssa_names ! && num_ssa_names > 0) ! free_df (); ! fprintf (file, "}\n"); check_bb_profile (EXIT_BLOCK_PTR, file); } Index: tree-dump.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/tree-dump.c,v retrieving revision 1.36 diff -c -3 -p -r1.36 tree-dump.c *** tree-dump.c 13 Oct 2004 13:48:16 -0000 1.36 --- tree-dump.c 15 Dec 2004 01:01:15 -0000 *************** static const struct dump_option_value_in *** 744,750 **** {"vops", TDF_VOPS}, {"lineno", TDF_LINENO}, {"uid", TDF_UID}, ! {"all", ~(TDF_RAW | TDF_SLIM | TDF_LINENO | TDF_TREE | TDF_RTL | TDF_IPA)}, {NULL, 0} }; --- 744,751 ---- {"vops", TDF_VOPS}, {"lineno", TDF_LINENO}, {"uid", TDF_UID}, ! {"notemp", TDF_NOTEMP}, ! {"all", ~(TDF_RAW | TDF_SLIM | TDF_LINENO | TDF_TREE | TDF_RTL | TDF_IPA | TDF_NOTEMP)}, {NULL, 0} }; Index: tree-optimize.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/tree-optimize.c,v retrieving revision 2.65 diff -c -3 -p -r2.65 tree-optimize.c *** tree-optimize.c 30 Nov 2004 15:38:33 -0000 2.65 --- tree-optimize.c 15 Dec 2004 01:01:15 -0000 *************** execute_todo (int properties, unsigned i *** 437,444 **** if ((flags & TODO_dump_func) && dump_file) { if (properties & PROP_trees) ! dump_function_to_file (current_function_decl, ! dump_file, dump_flags); else if (properties & PROP_cfg) print_rtl_with_bb (dump_file, get_insns ()); else --- 439,453 ---- if ((flags & TODO_dump_func) && dump_file) { if (properties & PROP_trees) ! { ! int flags = dump_flags; ! ! if (!(properties & PROP_ssa)) ! flags &= ~TDF_NOTEMP; ! ! dump_function_to_file (current_function_decl, ! dump_file, flags); ! } else if (properties & PROP_cfg) print_rtl_with_bb (dump_file, get_insns ()); else Index: tree-pretty-print.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/tree-pretty-print.c,v retrieving revision 2.52 diff -c -3 -p -r2.52 tree-pretty-print.c *** tree-pretty-print.c 9 Dec 2004 10:54:36 -0000 2.52 --- tree-pretty-print.c 15 Dec 2004 01:01:15 -0000 *************** dump_function_declaration (pretty_printe *** 217,222 **** --- 217,272 ---- pp_character (buffer, ')'); } + /* Checks whether VAR is used just as a temporary variable local to a single + basic block, and if it is the case, return the rhs of the defining + statement. Otherwise VAR is returned unchanged. */ + + static tree + temporary_use_rhs (tree var) + { + tree def_stmt, use_stmt, rhs; + dataflow_t df; + + if (TREE_CODE (var) != SSA_NAME + || !is_gimple_reg (var)) + return var; + + def_stmt = SSA_NAME_DEF_STMT (var); + if (TREE_CODE (def_stmt) != MODIFY_EXPR + || var != TREE_OPERAND (def_stmt, 0)) + return var; + rhs = TREE_OPERAND (def_stmt, 1); + + if (!is_gimple_val (rhs)) + { + /* Always propagate the simple constants and copies. Otherwise + check that there is an unique use in the same basic block. + + If it is completely unused, propagate anyway; this prevents + printing out dead statements. However if there are side + effects, show the statement! */ + if (TREE_SIDE_EFFECTS (rhs)) + return var; + + df = get_immediate_uses (def_stmt); + + if (num_immediate_uses (df) > 1) + return var; + else if (num_immediate_uses (df) == 1) + { + use_stmt = immediate_use (df, 0); + if (bb_for_stmt (use_stmt) != bb_for_stmt (def_stmt)) + return var; + } + } + + if (TREE_CODE (rhs) != SSA_NAME) + return rhs; + + /* Go back over chains of ssa name assignments. */ + return temporary_use_rhs (rhs); + } + /* Dump the domain associated with an array. */ static void *************** dump_generic_node (pretty_printer *buffe *** 659,664 **** --- 709,720 ---- op0 = TREE_OPERAND (op0, 0); str = "->"; } + + /* If we are replacing uses of temporaries, ensure that we take the + operation of the replacement into accout. */ + if (flags & TDF_NOTEMP) + op0 = temporary_use_rhs (op0); + if (op_prio (op0) < op_prio (node)) pp_character (buffer, '('); dump_generic_node (buffer, op0, spc, flags, false); *************** dump_generic_node (pretty_printer *buffe *** 692,697 **** --- 748,759 ---- case ARRAY_REF: case ARRAY_RANGE_REF: op0 = TREE_OPERAND (node, 0); + + /* If we are replacing uses of temporaries, ensure that we take the + operation of the replacement into accout. */ + if (flags & TDF_NOTEMP) + op0 = temporary_use_rhs (op0); + if (op_prio (op0) < op_prio (node)) pp_character (buffer, '('); dump_generic_node (buffer, op0, spc, flags, false); *************** dump_generic_node (pretty_printer *buffe *** 1014,1019 **** --- 1076,1089 ---- op0 = TREE_OPERAND (node, 0); op1 = TREE_OPERAND (node, 1); + /* If we are replacing uses of temporaries, ensure that we take the + operation of the replacement into accout. */ + if (flags & TDF_NOTEMP) + { + op0 = temporary_use_rhs (op0); + op1 = temporary_use_rhs (op1); + } + /* When the operands are expressions with less priority, keep semantics of the tree representation. */ if (op_prio (op0) < op_prio (node)) *************** dump_generic_node (pretty_printer *buffe *** 1052,1091 **** case ALIGN_INDIRECT_REF: case MISALIGNED_INDIRECT_REF: case INDIRECT_REF: if (TREE_CODE (node) == ADDR_EXPR ! && (TREE_CODE (TREE_OPERAND (node, 0)) == STRING_CST ! || TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL)) ; /* Do not output '&' for strings and function pointers. */ else pp_string (buffer, op_symbol (node)); ! if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node)) { pp_character (buffer, '('); ! dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false); pp_character (buffer, ')'); } else ! dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false); if (TREE_CODE (node) == MISALIGNED_INDIRECT_REF) ! { ! pp_string (buffer, "{misalignment: "); ! dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false); ! pp_character (buffer, '}'); ! } break; case POSTDECREMENT_EXPR: case POSTINCREMENT_EXPR: ! if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node)) { pp_character (buffer, '('); ! dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false); pp_character (buffer, ')'); } else ! dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false); pp_string (buffer, op_symbol (node)); break; --- 1122,1175 ---- case ALIGN_INDIRECT_REF: case MISALIGNED_INDIRECT_REF: case INDIRECT_REF: + op0 = TREE_OPERAND (node, 0); + + /* If we are replacing uses of temporaries, ensure that we take the + operation of the replacement into accout. */ + if (flags & TDF_NOTEMP) + op0 = temporary_use_rhs (op0); + if (TREE_CODE (node) == ADDR_EXPR ! && (TREE_CODE (op0) == STRING_CST ! || TREE_CODE (op0) == FUNCTION_DECL)) ; /* Do not output '&' for strings and function pointers. */ else pp_string (buffer, op_symbol (node)); ! if (op_prio (op0) < op_prio (node)) { pp_character (buffer, '('); ! dump_generic_node (buffer, op0, spc, flags, false); pp_character (buffer, ')'); } else ! dump_generic_node (buffer, op0, spc, flags, false); if (TREE_CODE (node) == MISALIGNED_INDIRECT_REF) ! { ! pp_string (buffer, "{misalignment: "); ! dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false); ! pp_character (buffer, '}'); ! } break; case POSTDECREMENT_EXPR: case POSTINCREMENT_EXPR: ! op0 = TREE_OPERAND (node, 0); ! ! /* If we are replacing uses of temporaries, ensure that we take the ! operation of the replacement into accout. */ ! if (flags & TDF_NOTEMP) ! op0 = temporary_use_rhs (op0); ! ! if (op_prio (op0) < op_prio (node)) { pp_character (buffer, '('); ! dump_generic_node (buffer, op0, spc, flags, false); pp_character (buffer, ')'); } else ! dump_generic_node (buffer, op0, spc, flags, false); pp_string (buffer, op_symbol (node)); break; *************** dump_generic_node (pretty_printer *buffe *** 1130,1135 **** --- 1214,1225 ---- dump_generic_node (buffer, type, spc, flags, false); pp_string (buffer, ") "); } + + /* If we are replacing uses of temporaries, ensure that we take the + operation of the replacement into accout. */ + if (flags & TDF_NOTEMP) + op0 = temporary_use_rhs (op0); + if (op_prio (op0) < op_prio (node)) pp_character (buffer, '('); dump_generic_node (buffer, op0, spc, flags, false); *************** dump_generic_node (pretty_printer *buffe *** 1414,1419 **** --- 1504,1523 ---- break; case SSA_NAME: + if (flags & TDF_NOTEMP) + { + /* If this ssa name has just an unique use inside the same basic + block as it is defined in, output rhs of definition instead the + ssa name. */ + tree tmp = temporary_use_rhs (node); + + if (TREE_CODE (tmp) != SSA_NAME) + { + dump_generic_node (buffer, tmp, spc, flags, false); + break; + } + } + dump_generic_node (buffer, SSA_NAME_VAR (node), spc, flags, false); pp_string (buffer, "_"); pp_decimal_int (buffer, SSA_NAME_VERSION (node)); *************** dump_generic_bb_buff (pretty_printer *bu *** 2338,2343 **** --- 2442,2456 ---- stmt = bsi_stmt (bsi); + if ((flags & TDF_NOTEMP) && TREE_CODE (stmt) == MODIFY_EXPR) + { + tree lhs = TREE_OPERAND (stmt, 0); + + /* If the statement just defines a temporary, do not print it. */ + if (lhs != temporary_use_rhs (lhs)) + continue; + } + curr_indent = TREE_CODE (stmt) == LABEL_EXPR ? label_indent : indent; INDENT (curr_indent); Index: tree.h =================================================================== RCS file: /cvs/gcc/gcc/gcc/tree.h,v retrieving revision 1.666 diff -c -3 -p -r1.666 tree.h *** tree.h 9 Dec 2004 10:54:38 -0000 1.666 --- tree.h 15 Dec 2004 01:01:16 -0000 *************** enum tree_dump_index *** 3842,3851 **** #define TDF_VOPS (1 << 6) /* display virtual operands */ #define TDF_LINENO (1 << 7) /* display statement line numbers */ #define TDF_UID (1 << 8) /* display decl UIDs */ ! #define TDF_TREE (1 << 9) /* is a tree dump */ ! #define TDF_RTL (1 << 10) /* is a RTL dump */ ! #define TDF_IPA (1 << 11) /* is an IPA dump */ typedef struct dump_info *dump_info_p; --- 3844,3854 ---- #define TDF_VOPS (1 << 6) /* display virtual operands */ #define TDF_LINENO (1 << 7) /* display statement line numbers */ #define TDF_UID (1 << 8) /* display decl UIDs */ + #define TDF_NOTEMP (1 << 9) /* eliminate temporaries from dumps */ ! #define TDF_TREE (1 << 10) /* is a tree dump */ ! #define TDF_RTL (1 << 11) /* is a RTL dump */ ! #define TDF_IPA (1 << 12) /* is an IPA dump */ typedef struct dump_info *dump_info_p;