On 2015.10.07 at 19:11 +0300, Maxim Ostapenko wrote:
> when testing OpenSSL performance, I found out that sometimes PGO-built
> binaries can actually introduce performance regressions. We could
> identify affected object files and disable PGO for them by simply
> removing corresponding .gcda file. However, even if profile data is not
> presented, GCC doesn't switch back -fprofile-use dependent optimizations
> (e.g. -fbranch-probabilities, -fvpt, etc). This may also lead to
> performance degradations.
>
> The issue had already raised quite time ago
> (https://gcc.gnu.org/ml/gcc-patches/2009-09/msg02119.html), but for some
> reasons wasn't discussed.
>
> Here a draft patch that disables -fprofile-use related optimizations if
> profile data wasn't found (perhaps it makes sense to introduce a special
> switch for this?). Does this look reasonable?
I find -fprofile-use a useful shortcut to: -fbranch-probabilities,
-fvpt, -funroll-loops, -fpeel-loops, -ftracer, -ftree-vectorize, and
ftree-loop-distribute-patterns.
There are many applications were the bulk of the speedup surprisingly
comes from these flags alone, even without any gcda file. E.g. with
tramp3d-v4 (-Ofast) I get ~5.3 percent speedup (without gcda) and an
additional 2.2 percent when using a gcda file.
> +/* Reset flags if a .gcda file is not found. */
> +static void
> +disable_profile_use_flags (void)
> +{
> + flag_branch_probabilities = flag_profile_values = flag_unroll_loops =
> false;
> + flag_value_profile_transformations
> + = flag_tree_loop_distribute_patterns = false;
> + flag_rename_registers = flag_peel_loops = false;
> + flag_profile_reorder_functions = flag_tracer = false;
> +}
Here you are disabling unrelated flags, e.g. flag_rename_registers.
--
Markus