[v3,0/4] ifcvt: Allow if conversion of arithmetic in basic blocks with multiple sets

Message ID 20230830101400.1539313-1-manolis.tsamis@vrull.eu
Headers
Series ifcvt: Allow if conversion of arithmetic in basic blocks with multiple sets |

Message

Manolis Tsamis Aug. 30, 2023, 10:13 a.m. UTC
  noce_convert_multiple_sets has been introduced and extended over time to handle
if conversion for blocks with multiple sets. Currently this is focused on
register moves and rejects any sort of arithmetic operations.

This series is an extension to allow more sequences to take part in if
conversion. The first patch is a required change to emit correct code and the
second patch whitelists a larger number of operations through
bb_ok_for_noce_convert_multiple_sets. The third patch adds support to rewire
multiple registers in noce_convert_multiple_sets_1 and refactors the code with
a new helper info struct. The fourth patch removes some old code that should
not be needed anymore.

For targets that have a rich selection of conditional instructions,
like aarch64, I have seen an ~5x increase of profitable if conversions for
multiple set blocks in SPEC benchmarks. Also tested with a wide variety of
benchmarks and I have not seen performance regressions on either x64 / aarch64.

Some samples that previously resulted in a branch but now better use these
instructions can be seen in the provided test cases.

Bootstrapped and tested on AArch64 and x86-64.


Changes in v3:
        - Add SCALAR_INT_MODE_P check in bb_ok_for_noce_convert_multiple_sets.
        - Allow rewiring of multiple regs.
        - Refactor code with noce_multiple_sets_info.
        - Remove old code for subregs.

Manolis Tsamis (4):
  ifcvt: handle sequences that clobber flags in
    noce_convert_multiple_sets
  ifcvt: Allow more operations in multiple set if conversion
  ifcvt: Handle multiple rewired regs and refactor
    noce_convert_multiple_sets
  ifcvt: Remove obsolete code for subreg handling in
    noce_convert_multiple_sets

 gcc/ifcvt.cc                                  | 403 ++++++++----------
 gcc/ifcvt.h                                   |  16 +
 .../aarch64/ifcvt_multiple_sets_arithm.c      |  79 ++++
 .../aarch64/ifcvt_multiple_sets_rewire.c      |  20 +
 4 files changed, 290 insertions(+), 228 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/aarch64/ifcvt_multiple_sets_arithm.c
 create mode 100644 gcc/testsuite/gcc.target/aarch64/ifcvt_multiple_sets_rewire.c
  

Comments

Manolis Tsamis Sept. 18, 2023, 8:18 a.m. UTC | #1
Kind ping for V3 of these ifcvt changes
https://gcc.gnu.org/pipermail/gcc-patches/2023-August/628820.html

Thanks,
Manolis

On Wed, Aug 30, 2023 at 1:14 PM Manolis Tsamis <manolis.tsamis@vrull.eu> wrote:
>
>
> noce_convert_multiple_sets has been introduced and extended over time to handle
> if conversion for blocks with multiple sets. Currently this is focused on
> register moves and rejects any sort of arithmetic operations.
>
> This series is an extension to allow more sequences to take part in if
> conversion. The first patch is a required change to emit correct code and the
> second patch whitelists a larger number of operations through
> bb_ok_for_noce_convert_multiple_sets. The third patch adds support to rewire
> multiple registers in noce_convert_multiple_sets_1 and refactors the code with
> a new helper info struct. The fourth patch removes some old code that should
> not be needed anymore.
>
> For targets that have a rich selection of conditional instructions,
> like aarch64, I have seen an ~5x increase of profitable if conversions for
> multiple set blocks in SPEC benchmarks. Also tested with a wide variety of
> benchmarks and I have not seen performance regressions on either x64 / aarch64.
>
> Some samples that previously resulted in a branch but now better use these
> instructions can be seen in the provided test cases.
>
> Bootstrapped and tested on AArch64 and x86-64.
>
>
> Changes in v3:
>         - Add SCALAR_INT_MODE_P check in bb_ok_for_noce_convert_multiple_sets.
>         - Allow rewiring of multiple regs.
>         - Refactor code with noce_multiple_sets_info.
>         - Remove old code for subregs.
>
> Manolis Tsamis (4):
>   ifcvt: handle sequences that clobber flags in
>     noce_convert_multiple_sets
>   ifcvt: Allow more operations in multiple set if conversion
>   ifcvt: Handle multiple rewired regs and refactor
>     noce_convert_multiple_sets
>   ifcvt: Remove obsolete code for subreg handling in
>     noce_convert_multiple_sets
>
>  gcc/ifcvt.cc                                  | 403 ++++++++----------
>  gcc/ifcvt.h                                   |  16 +
>  .../aarch64/ifcvt_multiple_sets_arithm.c      |  79 ++++
>  .../aarch64/ifcvt_multiple_sets_rewire.c      |  20 +
>  4 files changed, 290 insertions(+), 228 deletions(-)
>  create mode 100644 gcc/testsuite/gcc.target/aarch64/ifcvt_multiple_sets_arithm.c
>  create mode 100644 gcc/testsuite/gcc.target/aarch64/ifcvt_multiple_sets_rewire.c
>
> --
> 2.34.1
>
  
Manolis Tsamis Oct. 19, 2023, 6:53 a.m. UTC | #2
Hi all,

Pinging once more (
https://gcc.gnu.org/pipermail/gcc-patches/2023-August/628820.html).

Manolis

On Mon, Sep 18, 2023 at 11:18 AM Manolis Tsamis <manolis.tsamis@vrull.eu> wrote:
>
> Kind ping for V3 of these ifcvt changes
> https://gcc.gnu.org/pipermail/gcc-patches/2023-August/628820.html
>
> Thanks,
> Manolis
>
> On Wed, Aug 30, 2023 at 1:14 PM Manolis Tsamis <manolis.tsamis@vrull.eu> wrote:
> >
> >
> > noce_convert_multiple_sets has been introduced and extended over time to handle
> > if conversion for blocks with multiple sets. Currently this is focused on
> > register moves and rejects any sort of arithmetic operations.
> >
> > This series is an extension to allow more sequences to take part in if
> > conversion. The first patch is a required change to emit correct code and the
> > second patch whitelists a larger number of operations through
> > bb_ok_for_noce_convert_multiple_sets. The third patch adds support to rewire
> > multiple registers in noce_convert_multiple_sets_1 and refactors the code with
> > a new helper info struct. The fourth patch removes some old code that should
> > not be needed anymore.
> >
> > For targets that have a rich selection of conditional instructions,
> > like aarch64, I have seen an ~5x increase of profitable if conversions for
> > multiple set blocks in SPEC benchmarks. Also tested with a wide variety of
> > benchmarks and I have not seen performance regressions on either x64 / aarch64.
> >
> > Some samples that previously resulted in a branch but now better use these
> > instructions can be seen in the provided test cases.
> >
> > Bootstrapped and tested on AArch64 and x86-64.
> >
> >
> > Changes in v3:
> >         - Add SCALAR_INT_MODE_P check in bb_ok_for_noce_convert_multiple_sets.
> >         - Allow rewiring of multiple regs.
> >         - Refactor code with noce_multiple_sets_info.
> >         - Remove old code for subregs.
> >
> > Manolis Tsamis (4):
> >   ifcvt: handle sequences that clobber flags in
> >     noce_convert_multiple_sets
> >   ifcvt: Allow more operations in multiple set if conversion
> >   ifcvt: Handle multiple rewired regs and refactor
> >     noce_convert_multiple_sets
> >   ifcvt: Remove obsolete code for subreg handling in
> >     noce_convert_multiple_sets
> >
> >  gcc/ifcvt.cc                                  | 403 ++++++++----------
> >  gcc/ifcvt.h                                   |  16 +
> >  .../aarch64/ifcvt_multiple_sets_arithm.c      |  79 ++++
> >  .../aarch64/ifcvt_multiple_sets_rewire.c      |  20 +
> >  4 files changed, 290 insertions(+), 228 deletions(-)
> >  create mode 100644 gcc/testsuite/gcc.target/aarch64/ifcvt_multiple_sets_arithm.c
> >  create mode 100644 gcc/testsuite/gcc.target/aarch64/ifcvt_multiple_sets_rewire.c
> >
> > --
> > 2.34.1
> >