[Bug rtl-optimization/87047] [7/8/9 Regression] performance regression because of if-conversion

already5chosen at yahoo dot com gcc-bugzilla@gcc.gnu.org
Fri Aug 24 14:18:00 GMT 2018


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87047

--- Comment #11 from Michael_S <already5chosen at yahoo dot com> ---
Sorry for intervening, but IMHO a new __builtin is long overdue.
__builtin
(In reply to Jakub Jelinek from comment #9)
> (In reply to Alexander Monakov from comment #8)
> > Well, original_costs is already initialized with COSTS_N_INSNS (2),
> > accounting for test and branch that would be removed. So it's not too bad:
> > in pr78120.c else_bb is in fact missing.
> 
> I think that is not enough.
>  
> > (on x86 I think we shouldn't encourage if-conversion, by adding data
> > dependencies it can lengthen critical paths)
> 
> if-conversion is indeed very problematic on x86-64, but it isn't as easy as
> don't try to encourage it, because it slows down many important cases in
> that case if jumps are used.  We have many PRs where users ask on specific
> testcases for more x86 if-conversion, and many PRs where users ask for less
> or no if-conversion.

if-conversion, except for simplest shortest cases, is problematic on any
processor with good branch prediction and not very wide pipeline. Nothing
specific to x86-64 here. To something like ARM Cortex-A73 (dual-issue) it
applies much stronger than to Skylake or Ryzen.

If it was dependent on me then, starting from gcc9, I would apply automatic
(i.e. non-PGO) if-conversion only to *really* short sequences. For anything
longer, I'd request user hint in form of __builtin_expect_with_probability(,
0.5).


More information about the Gcc-bugs mailing list