Commit fca9dc00 by Zdenek Dvorak Committed by Zdenek Dvorak

Makefile.in (toplev.o): Add value-prof.h dependency.

	* Makefile.in (toplev.o): Add value-prof.h dependency.
	(value-prof.o): Add REGS_H dependency.
	* common.opt (fprofile-values, fvpt): New.
	* flags.h (flag_value_profile_transformations): Declare.
	* opts.c (common_handle_option): Handle -fprofile_values and
	-fvpt.
	* profile.c (branch_prob): Don't remove death notes here.
	* timevar.def (TV_VPT): New.
	* value-prof.c: Include regs.h.
	(insn_divmod_values_to_profile, gen_divmod_fixed_value, gen_mod_pow2,
	gen_mod_subtract, divmod_fixed_value_transform,mod_pow2_value_transform,
	mod_subtract_transform, value_profile_transformations): New.
	(insn_values_to_profile): Call insn_divmod_values_to_profile.
	(find_values_to_profile): Add dumps.
	* value-prof.h (value_profile_transformations): Declare.
	* toplev.c: Include value-prof.h.
	(rest_of_handle_value_profile_transformations): New.
	(enum dump_file_index): Add DFI_vpt.
	(dump_file): Add vpt dump.
	(flag_value_profile_transformations): New.
	(lang_independent_options): Add flag_profile_values and
	flag_value_profile_transformations.
	(rest_of_compilation): Call
	rest_of_handle_value_profile_transformations.
	(process_options): Let -fvpt imply -fprofile-values.
	* doc/invoke.texi (-fvpt): Document.

From-SVN: r72685
parent 47395a24
2003-10-19 Zdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz>
* Makefile.in (toplev.o): Add value-prof.h dependency.
(value-prof.o): Add REGS_H dependency.
* common.opt (fprofile-values, fvpt): New.
* flags.h (flag_value_profile_transformations): Declare.
* opts.c (common_handle_option): Handle -fprofile_values and
-fvpt.
* profile.c (branch_prob): Don't remove death notes here.
* timevar.def (TV_VPT): New.
* value-prof.c: Include regs.h.
(insn_divmod_values_to_profile, gen_divmod_fixed_value, gen_mod_pow2,
gen_mod_subtract, divmod_fixed_value_transform,mod_pow2_value_transform,
mod_subtract_transform, value_profile_transformations): New.
(insn_values_to_profile): Call insn_divmod_values_to_profile.
(find_values_to_profile): Add dumps.
* value-prof.h (value_profile_transformations): Declare.
* toplev.c: Include value-prof.h.
(rest_of_handle_value_profile_transformations): New.
(enum dump_file_index): Add DFI_vpt.
(dump_file): Add vpt dump.
(flag_value_profile_transformations): New.
(lang_independent_options): Add flag_profile_values and
flag_value_profile_transformations.
(rest_of_compilation): Call
rest_of_handle_value_profile_transformations.
(process_options): Let -fvpt imply -fprofile-values.
* doc/invoke.texi (-fvpt): Document.
2003-10-19 Jan Hubicka <jh@suse.cz> 2003-10-19 Jan Hubicka <jh@suse.cz>
* i386.c (print_reg): Do not abort on certain registers. * i386.c (print_reg): Do not abort on certain registers.
......
...@@ -1499,7 +1499,7 @@ toplev.o : toplev.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(RTL_ ...@@ -1499,7 +1499,7 @@ toplev.o : toplev.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(RTL_
function.h flags.h xcoffout.h input.h $(INSN_ATTR_H) output.h $(DIAGNOSTIC_H) \ function.h flags.h xcoffout.h input.h $(INSN_ATTR_H) output.h $(DIAGNOSTIC_H) \
debug.h insn-config.h intl.h $(RECOG_H) Makefile toplev.h \ debug.h insn-config.h intl.h $(RECOG_H) Makefile toplev.h \
dwarf2out.h sdbout.h dbxout.h $(EXPR_H) hard-reg-set.h $(BASIC_BLOCK_H) \ dwarf2out.h sdbout.h dbxout.h $(EXPR_H) hard-reg-set.h $(BASIC_BLOCK_H) \
graph.h $(LOOP_H) except.h $(REGS_H) $(TIMEVAR_H) \ graph.h $(LOOP_H) except.h $(REGS_H) $(TIMEVAR_H) value-prof.h \
ssa.h $(PARAMS_H) $(TM_P_H) reload.h dwarf2asm.h $(TARGET_H) \ ssa.h $(PARAMS_H) $(TM_P_H) reload.h dwarf2asm.h $(TARGET_H) \
langhooks.h insn-flags.h cfglayout.h real.h cfgloop.h \ langhooks.h insn-flags.h cfglayout.h real.h cfgloop.h \
hosthooks.h $(LANGHOOKS_DEF_H) cgraph.h $(COVERAGE_H) hosthooks.h $(LANGHOOKS_DEF_H) cgraph.h $(COVERAGE_H)
...@@ -1653,7 +1653,7 @@ profile.o : profile.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \ ...@@ -1653,7 +1653,7 @@ profile.o : profile.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
toplev.h $(BASIC_BLOCK_H) $(COVERAGE_H) $(TREE_H) value-prof.h toplev.h $(BASIC_BLOCK_H) $(COVERAGE_H) $(TREE_H) value-prof.h
value-prof.o : value-prof.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \ value-prof.o : value-prof.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
$(BASIC_BLOCK_H) hard-reg-set.h value-prof.h $(EXPR_H) output.h flags.h \ $(BASIC_BLOCK_H) hard-reg-set.h value-prof.h $(EXPR_H) output.h flags.h \
$(RECOG_H) insn-config.h $(OPTABS_H) $(RECOG_H) insn-config.h $(OPTABS_H) $(REGS_H)
loop.o : loop.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) flags.h $(LOOP_H) \ loop.o : loop.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) flags.h $(LOOP_H) \
insn-config.h $(REGS_H) hard-reg-set.h $(RECOG_H) $(EXPR_H) \ insn-config.h $(REGS_H) hard-reg-set.h $(RECOG_H) $(EXPR_H) \
real.h $(PREDICT_H) $(BASIC_BLOCK_H) function.h cfgloop.h \ real.h $(PREDICT_H) $(BASIC_BLOCK_H) function.h cfgloop.h \
......
...@@ -517,6 +517,10 @@ fprofile-arcs ...@@ -517,6 +517,10 @@ fprofile-arcs
Common Common
Insert arc-based program profiling code Insert arc-based program profiling code
fprofile-values
Common
Insert code to profile values of expressions
frandom-seed frandom-seed
Common Common
...@@ -719,6 +723,10 @@ fverbose-asm ...@@ -719,6 +723,10 @@ fverbose-asm
Common Common
Add extra commentary to assembler output Add extra commentary to assembler output
fvpt
Common
Use expression value profiles in optimizations
fweb fweb
Common Common
Construct webs and split unrelated uses of single variable Construct webs and split unrelated uses of single variable
......
...@@ -264,7 +264,7 @@ in the following sections. ...@@ -264,7 +264,7 @@ in the following sections.
@xref{Optimize Options,,Options that Control Optimization}. @xref{Optimize Options,,Options that Control Optimization}.
@gccoptlist{-falign-functions=@var{n} -falign-jumps=@var{n} @gol @gccoptlist{-falign-functions=@var{n} -falign-jumps=@var{n} @gol
-falign-labels=@var{n} -falign-loops=@var{n} @gol -falign-labels=@var{n} -falign-loops=@var{n} @gol
-fbranch-probabilities -fprofile-values -fbranch-target-load-optimize @gol -fbranch-probabilities -fprofile-values -fvpt -fbranch-target-load-optimize @gol
-fbranch-target-load-optimize2 -fcaller-saves -fcprop-registers @gol -fbranch-target-load-optimize2 -fcaller-saves -fcprop-registers @gol
-fcse-follow-jumps -fcse-skip-blocks -fdata-sections @gol -fcse-follow-jumps -fcse-skip-blocks -fdata-sections @gol
-fdelayed-branch -fdelete-null-pointer-checks @gol -fdelayed-branch -fdelete-null-pointer-checks @gol
...@@ -4564,6 +4564,16 @@ With @option{-fbranch-probabilities}, it reads back the data gathered ...@@ -4564,6 +4564,16 @@ With @option{-fbranch-probabilities}, it reads back the data gathered
from profiling values of expressions and adds @samp{REG_VALUE_PROFILE} from profiling values of expressions and adds @samp{REG_VALUE_PROFILE}
notes to instructions for their later usage in optimizations. notes to instructions for their later usage in optimizations.
@item -fvpt
@opindex fvpt
If combined with @option{-fprofile-arcs}, it instructs the compiler to add
a code to gather information about values of expressions.
With @option{-fbranch-probabilities}, it reads back the data gathered
and actually performs the optimizations based on them.
Currently the optimizations include specialization of division operation
using the knowledge about the value of the denominator.
@item -fnew-ra @item -fnew-ra
@opindex fnew-ra @opindex fnew-ra
Use a graph coloring register allocator. Currently this option is meant Use a graph coloring register allocator. Currently this option is meant
......
...@@ -680,6 +680,9 @@ extern int flag_gcse_sm; ...@@ -680,6 +680,9 @@ extern int flag_gcse_sm;
extern int flag_gcse_las; extern int flag_gcse_las;
/* Nonzero if value histograms should be used to optimize code. */
extern int flag_value_profile_transformations;
/* Perform branch target register optimization before prologue / epilogue /* Perform branch target register optimization before prologue / epilogue
threading. */ threading. */
......
...@@ -1182,6 +1182,14 @@ common_handle_option (size_t scode, const char *arg, ...@@ -1182,6 +1182,14 @@ common_handle_option (size_t scode, const char *arg,
profile_arc_flag = value; profile_arc_flag = value;
break; break;
case OPT_fprofile_values:
flag_profile_values = value;
break;
case OPT_fvpt:
flag_value_profile_transformations = value;
break;
case OPT_frandom_seed: case OPT_frandom_seed:
/* The real switch is -fno-random-seed. */ /* The real switch is -fno-random-seed. */
if (value) if (value)
......
...@@ -988,8 +988,6 @@ branch_prob (void) ...@@ -988,8 +988,6 @@ branch_prob (void)
allocate_reg_info (max_reg_num (), FALSE, FALSE); allocate_reg_info (max_reg_num (), FALSE, FALSE);
} }
if (flag_profile_values)
count_or_remove_death_notes (NULL, 1);
remove_fake_edges (); remove_fake_edges ();
free_aux_for_edges (); free_aux_for_edges ();
/* Re-merge split basic blocks and the mess introduced by /* Re-merge split basic blocks and the mess introduced by
......
...@@ -72,6 +72,7 @@ DEFTIMEVAR (TV_TRACER , "tracer") ...@@ -72,6 +72,7 @@ DEFTIMEVAR (TV_TRACER , "tracer")
DEFTIMEVAR (TV_WEB , "web") DEFTIMEVAR (TV_WEB , "web")
DEFTIMEVAR (TV_CSE2 , "CSE 2") DEFTIMEVAR (TV_CSE2 , "CSE 2")
DEFTIMEVAR (TV_BRANCH_PROB , "branch prediction") DEFTIMEVAR (TV_BRANCH_PROB , "branch prediction")
DEFTIMEVAR (TV_VPT , "value profile opts")
DEFTIMEVAR (TV_FLOW , "flow analysis") DEFTIMEVAR (TV_FLOW , "flow analysis")
DEFTIMEVAR (TV_COMBINE , "combiner") DEFTIMEVAR (TV_COMBINE , "combiner")
DEFTIMEVAR (TV_IFCVT , "if-conversion") DEFTIMEVAR (TV_IFCVT , "if-conversion")
......
...@@ -78,6 +78,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -78,6 +78,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "cgraph.h" #include "cgraph.h"
#include "opts.h" #include "opts.h"
#include "coverage.h" #include "coverage.h"
#include "value-prof.h"
#if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO) #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
#include "dwarf2out.h" #include "dwarf2out.h"
...@@ -137,6 +138,7 @@ static void rest_of_handle_null_pointer (tree, rtx); ...@@ -137,6 +138,7 @@ static void rest_of_handle_null_pointer (tree, rtx);
static void rest_of_handle_addressof (tree, rtx); static void rest_of_handle_addressof (tree, rtx);
static void rest_of_handle_cfg (tree, rtx); static void rest_of_handle_cfg (tree, rtx);
static void rest_of_handle_branch_prob (tree, rtx); static void rest_of_handle_branch_prob (tree, rtx);
static void rest_of_handle_value_profile_transformations (tree, rtx);
static void rest_of_handle_if_conversion (tree, rtx); static void rest_of_handle_if_conversion (tree, rtx);
static void rest_of_handle_if_after_combine (tree, rtx); static void rest_of_handle_if_after_combine (tree, rtx);
static void rest_of_handle_tracer (tree, rtx); static void rest_of_handle_tracer (tree, rtx);
...@@ -264,6 +266,7 @@ enum dump_file_index ...@@ -264,6 +266,7 @@ enum dump_file_index
DFI_bypass, DFI_bypass,
DFI_cfg, DFI_cfg,
DFI_bp, DFI_bp,
DFI_vpt,
DFI_ce1, DFI_ce1,
DFI_tracer, DFI_tracer,
DFI_web, DFI_web,
...@@ -296,7 +299,7 @@ enum dump_file_index ...@@ -296,7 +299,7 @@ enum dump_file_index
Remaining -d letters: Remaining -d letters:
" m q " " m q "
" JK O Q V Y " " JK O Q Y "
*/ */
static struct dump_file_info dump_file[DFI_MAX] = static struct dump_file_info dump_file[DFI_MAX] =
...@@ -318,6 +321,7 @@ static struct dump_file_info dump_file[DFI_MAX] = ...@@ -318,6 +321,7 @@ static struct dump_file_info dump_file[DFI_MAX] =
{ "bypass", 'G', 1, 0, 0 }, /* Yes, duplicate enable switch. */ { "bypass", 'G', 1, 0, 0 }, /* Yes, duplicate enable switch. */
{ "cfg", 'f', 1, 0, 0 }, { "cfg", 'f', 1, 0, 0 },
{ "bp", 'b', 1, 0, 0 }, { "bp", 'b', 1, 0, 0 },
{ "vpt", 'V', 1, 0, 0 },
{ "ce1", 'C', 1, 0, 0 }, { "ce1", 'C', 1, 0, 0 },
{ "tracer", 'T', 1, 0, 0 }, { "tracer", 'T', 1, 0, 0 },
{ "web", 'Z', 0, 0, 0 }, { "web", 'Z', 0, 0, 0 },
...@@ -404,6 +408,9 @@ int profile_arc_flag = 0; ...@@ -404,6 +408,9 @@ int profile_arc_flag = 0;
int flag_profile_values = 0; int flag_profile_values = 0;
/* Nonzero if value histograms should be used to optimize code. */
int flag_value_profile_transformations = 0;
/* Nonzero if generating info for gcov to calculate line test coverage. */ /* Nonzero if generating info for gcov to calculate line test coverage. */
int flag_test_coverage = 0; int flag_test_coverage = 0;
...@@ -1110,6 +1117,8 @@ static const lang_independent_options f_options[] = ...@@ -1110,6 +1117,8 @@ static const lang_independent_options f_options[] =
{"asynchronous-unwind-tables", &flag_asynchronous_unwind_tables, 1 }, {"asynchronous-unwind-tables", &flag_asynchronous_unwind_tables, 1 },
{"non-call-exceptions", &flag_non_call_exceptions, 1 }, {"non-call-exceptions", &flag_non_call_exceptions, 1 },
{"profile-arcs", &profile_arc_flag, 1 }, {"profile-arcs", &profile_arc_flag, 1 },
{"profile-values", &flag_profile_values, 1 },
{"vpt", &flag_value_profile_transformations, 1 },
{"test-coverage", &flag_test_coverage, 1 }, {"test-coverage", &flag_test_coverage, 1 },
{"branch-probabilities", &flag_branch_probabilities, 1 }, {"branch-probabilities", &flag_branch_probabilities, 1 },
{"profile", &profile_flag, 1 }, {"profile", &profile_flag, 1 },
...@@ -2462,6 +2471,7 @@ rest_of_handle_branch_prob (tree decl, rtx insns) ...@@ -2462,6 +2471,7 @@ rest_of_handle_branch_prob (tree decl, rtx insns)
timevar_push (TV_BRANCH_PROB); timevar_push (TV_BRANCH_PROB);
open_dump_file (DFI_bp, decl); open_dump_file (DFI_bp, decl);
if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities) if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
branch_prob (); branch_prob ();
...@@ -2481,6 +2491,20 @@ rest_of_handle_branch_prob (tree decl, rtx insns) ...@@ -2481,6 +2491,20 @@ rest_of_handle_branch_prob (tree decl, rtx insns)
timevar_pop (TV_BRANCH_PROB); timevar_pop (TV_BRANCH_PROB);
} }
/* Do optimizations based on expression value profiles. */
static void
rest_of_handle_value_profile_transformations (tree decl, rtx insns)
{
open_dump_file (DFI_vpt, decl);
timevar_push (TV_VPT);
if (value_profile_transformations ())
cleanup_cfg (CLEANUP_EXPENSIVE);
timevar_pop (TV_VPT);
close_dump_file (DFI_vpt, print_rtl_with_bb, insns);
}
/* Do control and data flow analysis; write some of the results to the /* Do control and data flow analysis; write some of the results to the
dump file. */ dump file. */
static void static void
...@@ -3345,8 +3369,19 @@ rest_of_compilation (tree decl) ...@@ -3345,8 +3369,19 @@ rest_of_compilation (tree decl)
if (optimize > 0 if (optimize > 0
|| profile_arc_flag || flag_test_coverage || flag_branch_probabilities) || profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
{
rest_of_handle_branch_prob (decl, insns); rest_of_handle_branch_prob (decl, insns);
if (flag_branch_probabilities
&& flag_profile_values
&& flag_value_profile_transformations)
rest_of_handle_value_profile_transformations (decl, insns);
/* Remove the death notes created for vpt. */
if (flag_profile_values)
count_or_remove_death_notes (NULL, 1);
}
if (optimize > 0) if (optimize > 0)
rest_of_handle_if_conversion (decl, insns); rest_of_handle_if_conversion (decl, insns);
...@@ -4228,6 +4263,9 @@ process_options (void) ...@@ -4228,6 +4263,9 @@ process_options (void)
if (flag_unit_at_a_time && ! lang_hooks.callgraph.expand_function) if (flag_unit_at_a_time && ! lang_hooks.callgraph.expand_function)
flag_unit_at_a_time = 0; flag_unit_at_a_time = 0;
if (flag_value_profile_transformations)
flag_profile_values = 1;
/* Warn about options that are not supported on this machine. */ /* Warn about options that are not supported on this machine. */
#ifndef INSN_SCHEDULING #ifndef INSN_SCHEDULING
if (flag_schedule_insns || flag_schedule_insns_after_reload) if (flag_schedule_insns || flag_schedule_insns_after_reload)
......
...@@ -61,3 +61,4 @@ struct histogram_value ...@@ -61,3 +61,4 @@ struct histogram_value
extern void find_values_to_profile (unsigned *, struct histogram_value **); extern void find_values_to_profile (unsigned *, struct histogram_value **);
extern void free_profiled_values (unsigned, struct histogram_value *); extern void free_profiled_values (unsigned, struct histogram_value *);
extern bool value_profile_transformations (void);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment