On 04/01/2017 06:20 AM, Jakub Jelinek wrote:
Hi!

As discussed in the PR, in the following testcase we don't if-convert
with the generic (and many other) tuning, because we default to
--param max-rtl-if-conversion-insns=1 in most of the tunings.
The problem we have is with multiple cmov instructions, but in the
testcase there is just one cmov and the other insn is turned into a SSE
max insn, which is fine.

This patch stops artificially lowering that param, and for one_if_conv_insn
tuning it instead rejects the if-conversion if the resulting sequence has
multiple cmov instructions.  The hook is passed if_info too, so it can
in the future do better heuristics based on predictability of the edges,
how far the uses of the cmov result are (I assume cmov major problem is
latency, right?) etc.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2017-04-01  Jakub Jelinek  <ja...@redhat.com>

        PR tree-optimization/79390
        * target.h (struct noce_if_info): Declare.
        * targhooks.h (default_noce_conversion_profitable_p): Declare.
        * target.def (noce_conversion_profitable_p): New target hook.
        * ifcvt.h (struct noce_if_info): New type, moved from ...
        * ifcvt.c (struct noce_if_info): ... here.
        (noce_conversion_profitable_p): Renamed to ...
        (default_noce_conversion_profitable_p): ... this.  No longer
        static nor inline.
        (noce_try_store_flag_constants, noce_try_addcc,
        noce_try_store_flag_mask, noce_try_cmove, noce_try_cmove_arith,
        noce_convert_multiple_sets): Use targetm.noce_conversion_profitable_p
        instead of noce_conversion_profitable_p.
        * config/i386/i386.c: Include ifcvt.h.
        (ix86_option_override_internal): Don't override
        PARAM_MAX_RTL_IF_CONVERSION_INSNS default.
        (ix86_noce_conversion_profitable_p): New function.
        (TARGET_NOCE_CONVERSION_PROFITABLE_P): Redefine.
        * config/i386/x86-tune.def (X86_TUNE_ONE_IF_CONV_INSN): Adjust comment.
        * doc/tm.texi.in (TARGET_NOCE_CONVERSION_PROFITABLE_P): Add.
        * doc/tm.texi: Regenerated.

        * gcc.target/i386/pr79390.c: New test.
        * gcc.dg/ifcvt-4.c: Use -mtune-ctrl=^one_if_conv_insn for i?86/x86_64.
OK.
jeff

Reply via email to