From cd8593c3e61c945dd27163965a95038211e1c01a Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Wed, 30 Jul 2008 01:11:08 +0000 Subject: [PATCH] Synchronized with edgfe: - add -f combo option - fixed cgana timing - moved tail-rec before call optimization (fixed fak.c) [r20780] --- driver/firm_cmdline.c | 3 ++ driver/firm_cmdline.h | 1 + driver/firm_opt.c | 66 +++++++++++++++++++++++++----------------- driver/firm_timing.def | 3 +- 4 files changed, 45 insertions(+), 28 deletions(-) diff --git a/driver/firm_cmdline.c b/driver/firm_cmdline.c index d78dc09..ae2edfa 100644 --- a/driver/firm_cmdline.c +++ b/driver/firm_cmdline.c @@ -26,6 +26,7 @@ struct a_firm_opt firm_opt = { /* reassoc = */ TRUE, /* cse = */ TRUE, /* control_flow = */ TRUE, + /* combo; = */ FALSE, /* gcse = */ TRUE, /* gvn_pre = */ FALSE, /* cond_eval = */ FALSE, @@ -128,6 +129,8 @@ static const struct params { { X("no-const-fold"), &firm_opt.const_folding, 0, "firm: disable constant folding" }, { X("control_flow"), &firm_opt.control_flow, 1, "firm: enable control flow optimization" }, { X("no-control-flow"), &firm_opt.control_flow, 0, "firm: disable control flow optimization" }, + { X("combo"), &firm_opt.combo, 1, "firm: enable combined CCE, UCE and GVN" }, + { X("no-combo"), &firm_opt.combo, 0, "firm: disable combined CCE, UCE and GVN" }, { X("gcse"), &firm_opt.gcse, 1, "firm: enable global common subexpression elimination" }, { X("no-gcse"), &firm_opt.gcse, 0, "firm: disable global common subexpression elimination" }, { X("gvn-pre"), &firm_opt.gvn_pre, 1, "firm: enable GVN partial redundancy elimination" }, diff --git a/driver/firm_cmdline.h b/driver/firm_cmdline.h index a34580b..6bae255 100644 --- a/driver/firm_cmdline.h +++ b/driver/firm_cmdline.h @@ -32,6 +32,7 @@ struct a_firm_opt { a_byte reassoc; /**< enable reassociation */ a_byte cse; /**< enable common-subexpression elimination */ a_byte control_flow; /**< enable control flow optimizations */ + a_byte combo; /**< enable combined CCE, UCE and GVN */ a_byte gcse; /**< enable global common-subexpression elimination */ a_byte gvn_pre; /**< enable global common-subexpression elimination and partial redundancy elimination */ diff --git a/driver/firm_opt.c b/driver/firm_opt.c index e4b07d5..d89e23d 100644 --- a/driver/firm_opt.c +++ b/driver/firm_opt.c @@ -309,27 +309,23 @@ static void do_firm_optimizations(const char *input_filename, int firm_const_exi timer_start(TV_ALL_OPT); - if (firm_opt.remove_unused) { - ir_entity **keep_methods; - int arr_len; - - /* Analysis that finds the free methods, - i.e. methods that are dereferenced. - Optimizes polymorphic calls :-). */ - cgana(&arr_len, &keep_methods); - - /* Remove methods that are never called. */ - gc_irgs(arr_len, keep_methods); - - free(keep_methods); - } - if (! firm_opt.freestanding) { rts_map(); DUMP_ALL_C(firm_dump.ir_graph && firm_dump.all_phases, "rts"); CHECK_ALL(firm_opt.check_all); } + if (firm_opt.combo) { + for (i = 0; i < get_irp_n_irgs(); i++) { + timer_push(TV_COMBO); + irg = get_irp_irg(i); + combo(irg); + timer_pop(); + DUMP_ONE_C(firm_dump.ir_graph && firm_dump.all_phases, irg, "combo"); + CHECK_ONE(firm_opt.check_all, irg); + } + } + /* first step: kill dead code */ for (i = 0; i < get_irp_n_irgs(); i++) { irg = current_ir_graph = get_irp_irg(i); @@ -342,6 +338,31 @@ static void do_firm_optimizations(const char *input_filename, int firm_const_exi timer_pop(); } + if (firm_opt.remove_unused) { + ir_entity **keep_methods; + int arr_len; + + timer_push(TV_CGANA); + /* Analysis that finds the free methods, + i.e. methods that are dereferenced. + Optimizes polymorphic calls :-). */ + cgana(&arr_len, &keep_methods); + + /* Remove methods that are never called. */ + gc_irgs(arr_len, keep_methods); + + free(keep_methods); + timer_pop(); + } + + if (firm_opt.tail_rec) { + timer_push(TV_TAIL_REC); + opt_tail_recursion(); + timer_pop(); + + DUMP_ALL_C(firm_dump.ir_graph && firm_dump.all_phases, "tail_rec"); + CHECK_ALL(firm_opt.check_all); + } if (firm_opt.func_calls) { timer_push(TV_REAL_FUNC_CALL); optimize_funccalls(firm_const_exists, NULL); @@ -550,14 +571,6 @@ static void do_firm_optimizations(const char *input_filename, int firm_const_exi DUMP_ALL_C(firm_dump.ir_graph && firm_dump.all_phases, "clone"); CHECK_ALL(firm_opt.check_all); } - if (firm_opt.tail_rec) { - timer_push(TV_TAIL_REC); - opt_tail_recursion(); - timer_pop(); - - DUMP_ALL_C(firm_dump.ir_graph && firm_dump.all_phases, "tail_rec"); - CHECK_ALL(firm_opt.check_all); - } if (firm_opt.cond_eval) { for (i = 0; i < get_irp_n_irgs(); i++) { @@ -596,6 +609,7 @@ static void do_firm_optimizations(const char *input_filename, int firm_const_exi ir_entity **keep_methods; int arr_len; + timer_push(TV_CGANA); /* Analysis that finds the free methods, i.e. methods that are dereferenced. Optimizes polymorphic calls :-). */ @@ -605,6 +619,7 @@ static void do_firm_optimizations(const char *input_filename, int firm_const_exi gc_irgs(arr_len, keep_methods); free(keep_methods); + timer_pop(); } @@ -1130,11 +1145,8 @@ void gen_firm_finish(FILE *out, const char *input_filename, int c_mode, int firm stat_dump_snapshot(input_filename, "noopt"); } - if (firm_opt.enabled) { + if (firm_opt.enabled) do_firm_optimizations(input_filename, firm_const_exists); - //do_firm_optimizations(input_filename, firm_const_exists); - //do_firm_optimizations(input_filename, firm_const_exists); - } if (firm_dump.gen_firm_asm) { timer_push(TV_FIRM_ASM); diff --git a/driver/firm_timing.def b/driver/firm_timing.def index d8da2ac..afce33a 100644 --- a/driver/firm_timing.def +++ b/driver/firm_timing.def @@ -3,11 +3,12 @@ * * (C) 2006 Michael Beck beck@ipd.info.uni-karlsruhe.de * - * $Id: firm_timing.def 14048 2007-05-26 10:43:19Z mallon $ + * $Id: firm_timing.def 20710 2008-07-26 19:59:07Z beck $ */ DEFTIMEVAR(TV_ALL_OPT , "allopt", "Firm: all optimizations") DEFTIMEVAR(TV_VALUE_NUM , "valnum", "Firm: value numbers") DEFTIMEVAR(TV_CREATE , "create", "Firm: creation") +DEFTIMEVAR(TV_COMBO , "combo", "Firm: combo") DEFTIMEVAR(TV_INLINE , "inline", "Firm: inlining") DEFTIMEVAR(TV_TAIL_REC , "tailrec", "Firm: tail-recursion") DEFTIMEVAR(TV_COMP_DOMS , "doms", "Firm: compute doms") -- 2.20.1