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

--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jakub Jelinek
<ja...@gcc.gnu.org>:

https://gcc.gnu.org/g:7151b3d700efcd0994bc1a6cfc36f5abc53c7f5a

commit r10-8667-g7151b3d700efcd0994bc1a6cfc36f5abc53c7f5a
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Wed Aug 12 17:00:41 2020 +0200

    Fix up flag_cunroll_grow_size handling in presence of optimize attr
[PR96535]

    As the testcase in the PR shows (not included in the patch, as
    it seems quite fragile to observe unrolling in the IL), the introduction of
    flag_cunroll_grow_size broke optimize attribute related to loop unrolling.
    The problem is that the new option flag is set (if not set explicitly) only
    in process_options and in rs6000_option_override_internal (and there only
if
    global_init_p).  So, this means that while it is Optimization option, it
    will only be set based on the command line -funroll-loops/-O3/-fpeel-loops
    or -funroll-all-loops, which means that if command line does include any of
    those, it is enabled even for functions that will through optimize
attribute
    have all of those disabled, and if command line does not include those,
    it will not be enabled for functions that will through optimize attribute
    have any of those enabled.

    process_options is called just once, so IMHO it should be handling only
    non-Optimization option adjustments (various other options suffer from that
    too, but as this is a regression from 10.1 on the 10 branch, changing those
    is not appropriate).  Similarly, rs6000_option_override_internal is called
    only once (with global_init_p) and then for target attribute handling, but
    not for optimize attribute handling.

    This patch moves the unrolling related handling from process_options into
    finish_options which is invoked whenever the options are being finalized,
    and the rs6000 specific parts into the override_options_after_change hook
    which is called for optimize attribute handling (and unfortunately also
    th cfun changes, but what the hook does is cheap) and I've added a call to
    that from rs6000_override_options_internal, so it is also called on cmdline
    processing and for target attribute.

    Furthermore, it stops using AUTODETECT_VALUE, which can work only once,
    and instead uses the global_options_set.x_... flags.

    2020-08-12  Jakub Jelinek  <ja...@redhat.com>

            PR tree-optimization/96535
            * toplev.c (process_options): Move flag_unroll_loops and
            flag_cunroll_grow_size handling from here to ...
            * opts.c (finish_options): ... here.  For flag_cunroll_grow_size,
            don't check for AUTODETECT_VALUE, but instead check
            opts_set->x_flag_cunroll_grow_size.
            * common.opt (funroll-completely-grow-size): Default to 0.
            * config/rs6000/rs6000.c (TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE):
            Redefine.
            (rs6000_override_options_after_change): New function.
            (rs6000_option_override_internal): Call it.  Move there the
            flag_cunroll_grow_size, unroll_only_small_loops and
            flag_rename_registers handling.

    (cherry picked from commit fe9458c280dbd6e8b892db4ca3b64185049c376b)

Reply via email to