diff options
author | Honza <jh@ryzen3.suse.cz> | 2023-05-09 16:26:00 +0200 |
---|---|---|
committer | Honza <jh@ryzen3.suse.cz> | 2023-05-09 16:26:00 +0200 |
commit | 5cbb9db198cdfae17dbfff495aafc79386acf2c7 (patch) | |
tree | 97d32ad4a53925d771400e5743bd3cddaea6e764 | |
parent | 2ad072527291c3fcf3a8e9d4dda4cb548f4f75df (diff) |
Add parameters to control histogram profiling and peeling
-rw-r--r-- | gcc/common.opt | 10 | ||||
-rw-r--r-- | gcc/gimple-loop-versioning-histograms.cc | 2 | ||||
-rw-r--r-- | gcc/params.opt | 8 | ||||
-rw-r--r-- | gcc/tree-ssa-loop-ivcanon.cc | 11 | ||||
-rw-r--r-- | gcc/value-prof.cc | 2 |
5 files changed, 28 insertions, 5 deletions
diff --git a/gcc/common.opt b/gcc/common.opt index 5b1633cb5ac..ff44d84bcd5 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -2293,7 +2293,11 @@ Perform loop peeling. fuse-histograms-in-peeling Common Var(flag_use_histogram_in_peeling) Init(1) Optimization -Use histograms in loop peelings. +Use histograms in loop peeling heuristics. + +fpeel-loops-without-histogram +Common Var(flag_peel_loops_without_histogram) Init(1) Optimization +Peel also loop with no loop histogram. fpeephole Common Var(flag_no_peephole,0) Optimization @@ -2392,6 +2396,10 @@ fprofile-reproducible= Common Joined RejectNegative Var(flag_profile_reproducible) Enum(profile_reproducibility) Init(PROFILE_REPRODUCIBILITY_SERIAL) -fprofile-reproducible=[serial|parallel-runs|multithreaded] Control level of reproducibility of profile gathered by -fprofile-generate. +fprofile-loops +Common Var(flag_profile_loops) Init(1) Optimization +Profile loop histograms. + Enum Name(profile_update) Type(enum profile_update) UnknownError(unknown profile update method %qs) diff --git a/gcc/gimple-loop-versioning-histograms.cc b/gcc/gimple-loop-versioning-histograms.cc index 1e39aa66bd5..6abe4d3e9b1 100644 --- a/gcc/gimple-loop-versioning-histograms.cc +++ b/gcc/gimple-loop-versioning-histograms.cc @@ -118,7 +118,7 @@ pass_loop_histogram_versioning::execute (function *fn) best_iters = i; } } - if (best_val <= 0 || best_val < loop->counters->sum * 9 / 10) + if (best_val <= 0 || best_val < loop->counters->sum * param_loop_versioning_histogram_prcnt / 100) continue; if (dump_file) fprintf (dump_file, "Loop %i has dominating number of iterations %i\n", diff --git a/gcc/params.opt b/gcc/params.opt index 72f6a474b4e..9f32d551ace 100644 --- a/gcc/params.opt +++ b/gcc/params.opt @@ -426,6 +426,10 @@ The maximum number of instructions in an inner loop that is being considered for Common Joined UInteger Var(param_loop_versioning_max_outer_insns) Init(100) Param Optimization The maximum number of instructions in an outer loop that is being considered for versioning, on top of the instructions in inner loops. +-param=loop-versioning-histogram_prcnts= +Common Joined UInteger Var(param_loop_versioning_histogram_prcnt) Init(30) Param Optimization +Percentage of the dominating iteration count required for versioning. + -param=lra-inheritance-ebb-probability-cutoff= Common Joined UInteger Var(param_lra_inheritance_ebb_probability_cutoff) Init(40) IntegerRange(0, 100) Param Optimization Minimal fall-through edge probability in percentage used to add BB to inheritance EBB in LRA. @@ -890,6 +894,10 @@ Size of the linear portion of the histogram counter for profile feedback. Common Joined UInteger Var(param_profile_histogram_peel_prcnt) Init(6) Param Optimization Peels if it can eliminate at least this percentage per 1 peeling. +-param=profile-histogram-peel-overall-prcnt= +Common Joined UInteger Var(param_profile_histogram_peel_overall_prcnt) Init(30) Param Optimization +Peels if it can eliminate at least this percentage of executions of the loop. + -param=profile-func-internal-id= Common Joined UInteger Var(param_profile_func_internal_id) IntegerRange(0, 1) Param Use internal function id in profile lookup. diff --git a/gcc/tree-ssa-loop-ivcanon.cc b/gcc/tree-ssa-loop-ivcanon.cc index f0066d00ee8..5483a4aba9a 100644 --- a/gcc/tree-ssa-loop-ivcanon.cc +++ b/gcc/tree-ssa-loop-ivcanon.cc @@ -1122,17 +1122,22 @@ try_peel_loop (class loop *loop, gcov_type sum = loop->counters->sum; gcov_type rest = sum; gcov_type psum = 0; + gcov_type osum = 0; int good_percentage = param_profile_histogram_peel_prcnt; + int good_overall_percentage = param_profile_histogram_peel_overall_prcnt; for (int i = 0; i < (int)loop->counters->lin->length (); i++) { - psum += (*(loop->counters->lin))[i]; + gcov_type e = (*(loop->counters->lin))[i]; + psum += e; + osum += e; if ((maxiter >= 0 && maxiter <= i) || (i >= param_max_peel_times - 1) || rest == 0) break; // iteration has enough cumulated in partial sum and itself has at // least 1 percent or we have complete peeling - if ((100 * psum) / sum >= good_percentage || psum == rest) + if (e && ((100 * psum) / sum >= good_percentage || psum == rest) + && ((100 * osum) / sum) >= good_overall_percentage) { prcnt.safe_push (prcnt.last () + (100 * psum) / sum); good_peels.safe_push (i); @@ -1152,7 +1157,7 @@ try_peel_loop (class loop *loop, { if (dump_file) fprintf (dump_file, - "Not peeling: found no good candidates in th ehistogram\n"); + "Not peeling: found no good candidates in the histogram\n"); return false; } } diff --git a/gcc/value-prof.cc b/gcc/value-prof.cc index 777ea47d063..f79dedd74fb 100644 --- a/gcc/value-prof.cc +++ b/gcc/value-prof.cc @@ -1950,6 +1950,8 @@ gimple_stringops_values_to_profile (gimple *gs, histogram_values *values) static void gimple_histogram_values_to_profile (function *fun, histogram_values *values) { + if (!flag_profile_loops) + return; for (auto loop : loops_list (fun, 0)) { tree var; |