> > Setting PARAM_EARLY_INLINING_INSNS to 0 when FDO is enabled should be > > equivalent to my patch. > > Yes. This means it's easy to experiment with other values than zero. > Basically > early inlining is supposed to remove abstraction penalty to > > a) reduce FDO instrumentation overhead > b) get more realistic size estimates for the inliner > > a) was particularly important back in time for tramp3d, reducing > profiling runtime > 1000-fold. b) is generally important. > > PARAM_EARLY_INLINING_INSNS is supposed to be a reasonable value to > get abstraction removed but IIRC we increased it quite a bit to also get more > early optimization (to get more accurate inliner estimates). > > What I am saying is that reducing PARAM_EARLY_INLINING_INSNS makes > sense for FDO but reducing it to zero is probably a bit much. > > Can you do your measurements with values between zero and the current > default of 14 (wow, 14 ... didn't know it's _that_ high currently ;)). > What's the > value that crosses the boundary of diminishing returns regarding to code-size > improvements for you? > > Richard.
Here are the results: Param Size (GCC5) Time (GCC5) Time (GCC7) 0 44686265 (-8.26%) 58.772s 66.332s 1 45692793 (-6.19%) 40.684s 39.220s 2 45556185 (-6.47%) 35.292s 34.328s 3 46251049 (-5.05%) 28.820s 27.136s 4 47028873 (-3.45%) 24.616s 22.200s 5 47495641 (-2.49%) 20.160s 17.800s 6 47520153 (-2.44%) 16.444s 15.656s 14 48708873 5.620s 5.556s Param: value of PARAM_EARLY_INLINING_INSNS Size: code size (.text) of optimized libxul.so Time: execution time of instrumented tramp3d (-n 25) To balance between size reduction of optimized binary and speed penalty of instrumented binary, I set param=6 as baseline and compare: Param Size score Time score Total 0 3.39 -3.57 -0.18 1 2.54 -2.47 0.07 2 2.65 -2.15 0.50 3 2.07 -1.75 0.32 4 1.41 -1.50 -0.09 5 1.02 -1.23 -0.21 6 1.00 -1.00 0.00 14 0.00 -0.34 -0.34 Therefore, I think param=2 is the best choice. Is the attached patch OK? Regards, Yuan, Pengfei gcc/ChangeLog * opts.c (finish_options): Adjust PARAM_EARLY_INLINING_INSNS when FDO is enabled. diff --git a/gcc/opts.c b/gcc/opts.c index 39c190d..b59c700 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -826,8 +826,14 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set, maybe_set_param_value (PARAM_STACK_FRAME_GROWTH, 40, opts->x_param_values, opts_set->x_param_values); } + /* Adjust PARAM_EARLY_INLINING_INSNS when FDO is enabled. */ + if ((opts->x_profile_arc_flag && !opts->x_flag_test_coverage) + || (opts->x_flag_branch_probabilities && !opts->x_flag_auto_profile)) + maybe_set_param_value (PARAM_EARLY_INLINING_INSNS, 2, + opts->x_param_values, opts_set->x_param_values); + if (opts->x_flag_lto) { #ifdef ENABLE_LTO opts->x_flag_generate_lto = 1;