X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=driver%2Ffirm_opt.c;h=8d3d3fa2ec30f4f859043252632aa39a44fcd1fa;hb=2058211f61e90b3acfcce898516274e84c314c8b;hp=3eff5f03ee62b1f72d8af6079b37acf0ccde4449;hpb=098ba001486fc4336ad43e8364aa74adc0fae9a1;p=cparser diff --git a/driver/firm_opt.c b/driver/firm_opt.c index 3eff5f0..8d3d3fa 100644 --- a/driver/firm_opt.c +++ b/driver/firm_opt.c @@ -300,10 +300,6 @@ static void do_firm_optimizations(const char *input_filename, int firm_const_exi set_opt_auto_create_sync(firm_opt.auto_sync); set_opt_alias_analysis(firm_opt.alias_analysis); - /* Overflow unsafe transformation can be enabled here if OSR is disabled, else - must be disabled until OSR finished. */ - set_opt_overflow_unsafe_transform(firm_opt.strength_red == FALSE); - aa_opt = aa_opt_no_opt; if (firm_opt.strict_alias) aa_opt |= aa_opt_type_based | aa_opt_byte_type_may_alias; @@ -335,13 +331,16 @@ static void do_firm_optimizations(const char *input_filename, int firm_const_exi CHECK_ALL(firm_opt.check_all); } - if (firm_opt.tail_rec) { - timer_push(TV_TAIL_REC); - opt_tail_recursion(); + /* first step: kill dead code */ + for (i = 0; i < get_irp_n_irgs(); i++) { + irg = current_ir_graph = get_irp_irg(i); + /* Confirm construction currently can only handle blocks with only one control + flow predecessor. Calling optimize_cf here removes Bad predecessors and help + the optimization of switch constructs. */ + timer_push(TV_CF_OPT); + optimize_graph_df(irg); + optimize_cf(irg); 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) { @@ -352,21 +351,12 @@ static void do_firm_optimizations(const char *input_filename, int firm_const_exi CHECK_ALL(firm_opt.check_all); } - if (firm_opt.do_inline) { - timer_push(TV_INLINE); - inline_leave_functions(500, 80, 30, FALSE); - timer_pop(); - DUMP_ALL_C(firm_dump.ir_graph && firm_dump.all_phases, "inl"); - CHECK_ALL(firm_opt.check_all); - } - /* do lowering on the const code irg */ lower_const_code(); for (i = 0; i < get_irp_n_irgs(); i++) { irg = current_ir_graph = get_irp_irg(i); - #ifdef FIRM_EXT_GRS /* If SIMD optimization is on, make sure we have only 1 return */ if (firm_ext_grs.create_pattern || firm_ext_grs.simd_opt) @@ -461,14 +451,6 @@ static void do_firm_optimizations(const char *input_filename, int firm_const_exi irg_verify(irg, VRFY_ENFORCE_SSA); } - if (firm_opt.loop_unrolling) { - timer_push(TV_LOOP_UNROLL); - optimize_loop_unrolling(irg); - timer_pop(); - DUMP_ONE_C(firm_dump.ir_graph && firm_dump.all_phases, irg, "loop"); - CHECK_ONE(firm_opt.check_all, irg); - } - if (firm_opt.load_store) { timer_push(TV_LOAD_STORE); optimize_load_store(irg); @@ -533,8 +515,6 @@ static void do_firm_optimizations(const char *input_filename, int firm_const_exi timer_push(TV_OSR); opt_osr(current_ir_graph, osr_flag_default | osr_flag_keep_reg_pressure | osr_flag_ignore_x86_shift); - /* now it is safe to enable overflow unsafe transformations */ - set_opt_overflow_unsafe_transform(1); timer_pop(); DUMP_ONE_C(firm_dump.ir_graph && firm_dump.all_phases, irg, "stred"); CHECK_ONE(firm_opt.check_all, irg); @@ -553,11 +533,24 @@ static void do_firm_optimizations(const char *input_filename, int firm_const_exi CHECK_ONE(firm_opt.check_all, irg); } + if (firm_opt.do_inline) { + inline_functions(500, 50); + DUMP_ALL_C(firm_dump.ir_graph && firm_dump.all_phases, "inl"); + CHECK_ALL(firm_opt.check_all); + } if (firm_opt.cloning) { proc_cloning((float)firm_opt.clone_threshold); 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_dump.ir_graph) { /* recompute backedges for nicer dumps */ @@ -584,8 +577,10 @@ static void do_firm_optimizations(const char *input_filename, int firm_const_exi DUMP_ALL(firm_dump.ir_graph, "-opt"); /* verify optimized graphs */ - for (i = get_irp_n_irgs() - 1; i >= 0; --i) - irg_verify(get_irp_irg(i), VRFY_ENFORCE_SSA); + for (i = get_irp_n_irgs() - 1; i >= 0; --i) { + ir_graph *irg = get_irp_irg(i); + irg_verify(irg, VRFY_ENFORCE_SSA); + } if (firm_dump.statistic & STAT_AFTER_OPT) stat_dump_snapshot(input_filename, "opt"); @@ -728,24 +723,14 @@ static int compute_type_size(ir_type *ty) } /* compute_type_size */ /** - * layout all types of the Firm graph + * layout all non-frame types of the Firm graph */ static void compute_type_sizes(void) { int i; ir_type *tp; - ir_graph *irg; - - /* all frame types */ - for (i = get_irp_n_irgs() - 1; i >= 0; --i) { - irg = get_irp_irg(i); - /* do not optimize away variables in debug mode */ - if (firm_opt.debug_mode == DBG_MODE_NONE) - opt_frame_irg(irg); - compute_type_size(get_irg_frame_type(irg)); - } - /* all other types */ + /* all non-frame other types */ for (i = get_irp_n_types() - 1; i >= 0; --i) { tp = get_irp_type(i); compute_type_size(tp); @@ -761,6 +746,24 @@ static void compute_type_sizes(void) } } /* compute_type_sizes */ +/** + * layout all frame-types of the Firm graph + */ +static void compute_frame_type_sizes(void) +{ + int i; + ir_graph *irg; + + /* all frame types */ + for (i = get_irp_n_irgs() - 1; i >= 0; --i) { + irg = get_irp_irg(i); + /* do not optimize away variables in debug mode */ + if (firm_opt.debug_mode == DBG_MODE_NONE) + opt_frame_irg(irg); + compute_type_size(get_irg_frame_type(irg)); + } +} /* compute_frame_type_sizes */ + /** * do Firm lowering * @@ -796,7 +799,6 @@ static void do_firm_lowering(const char *input_filename) } timer_push(TV_DW_LOWER); lower_dw_ops(&init); - DUMP_ALL(firm_dump.ir_graph, "-dw"); timer_pop(); } @@ -848,7 +850,6 @@ static void do_firm_lowering(const char *input_filename) CHECK_ONE(firm_opt.check_all, current_ir_graph); } -// set_opt_global_cse(0); timer_push(TV_LOAD_STORE); optimize_load_store(current_ir_graph); timer_pop(); @@ -960,6 +961,9 @@ void gen_firm_init(void) set_opt_precise_exc_context(firm_opt.precise_exc); set_opt_fragile_ops(firm_opt.fragile_ops); + /* Sel node cannot produce NULL pointers */ + set_opt_sel_based_null_check_elim(1); + /* dynamic dispatch works currently only if whole world scenarios */ set_opt_dyn_meth_dispatch(0); @@ -1058,6 +1062,12 @@ void gen_firm_finish(FILE *out, const char *input_filename, int c_mode, int firm /* computes the sizes of all types that are still not computed */ compute_type_sizes(); + /* lower copyb nodes */ + for (i = get_irp_n_irgs() - 1; i >= 0; --i) { + ir_graph *irg = get_irp_irg(i); + lower_CopyB(irg, 128, 4); + } + if (firm_dump.statistic & STAT_BEFORE_OPT) { stat_dump_snapshot(input_filename, "noopt"); } @@ -1075,6 +1085,9 @@ void gen_firm_finish(FILE *out, const char *input_filename, int c_mode, int firm if (firm_opt.lower) do_firm_lowering(input_filename); + /* computes the sizes of all frame types */ + compute_frame_type_sizes(); + /* set the phase to low */ for (i = get_irp_n_irgs() - 1; i >= 0; --i) set_irg_phase_low(get_irp_irg(i));