Ping. https://gcc.gnu.org/pipermail/gcc-patches/2026-November/737204.html Thanks, Kyrill
> On 2 Nov 2026, at 15:19, Kyrylo Tkachov <[email protected]> wrote: > > From: Kyrylo Tkachov <[email protected]> > > The AArch64 speed profitability check adds serial instruction costs for > conditional-select sequences inside loops. It can reject short > independent register computations that fit within the target's issue > rate and cost limit, so a block that computes two values that do not > depend on each other and selects between them keeps its branch. > > Export noce_parallel_seq_cost and use it in the AArch64 speed check. > Sequences it cannot model keep the serial cost. Keep the target cost > limit, the instruction-shape checks and the in-loop size policy. > > Add a loop test where two independent outputs now convert, guard tests > where a long dependent chain and low explicit cost limits keep the > branch and where -Os and -Oz still convert. > > This improves Snappy compress performance by 4.7% on NVIDIA Vera. > Bootstrapped and tested on aarch64-none-linux-gnu. > Ok for trunk? > Thanks, > Kyrill > > Cc: Tamar Christina <[email protected]> > > gcc/ChangeLog: > > * ifcvt.cc (noce_parallel_seq_cost): Remove static. > * ifcvt.h (noce_parallel_seq_cost): Declare. > * config/aarch64/aarch64.cc > (aarch64_noce_conversion_profitable_p): Use noce_parallel_seq_cost. > > gcc/testsuite/ChangeLog: > > * gcc.target/aarch64/noce-parallel-cost-1.c: New test. > * gcc.target/aarch64/noce-parallel-cost-2.c: Likewise. > * gcc.target/aarch64/noce-parallel-cost-3.c: Likewise. > * gcc.target/aarch64/noce-parallel-cost-4.c: Likewise. > * gcc.target/aarch64/noce-parallel-cost-5.c: Likewise. > > Signed-off-by: Kyrylo Tkachov <[email protected]> > --- > gcc/config/aarch64/aarch64.cc | 2 +- > gcc/ifcvt.cc | 2 +- > gcc/ifcvt.h | 2 ++ > .../gcc.target/aarch64/noce-parallel-cost-1.c | 27 +++++++++++++++ > .../gcc.target/aarch64/noce-parallel-cost-2.c | 34 +++++++++++++++++++ > .../gcc.target/aarch64/noce-parallel-cost-3.c | 6 ++++ > .../gcc.target/aarch64/noce-parallel-cost-4.c | 6 ++++ > .../gcc.target/aarch64/noce-parallel-cost-5.c | 6 ++++ > 8 files changed, 83 insertions(+), 2 deletions(-) > create mode 100644 gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-1.c > create mode 100644 gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-2.c > create mode 100644 gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-3.c > create mode 100644 gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-4.c > create mode 100644 gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-5.c > > diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc > index 7a73a441f98..282be9a9b1c 100644 > --- a/gcc/config/aarch64/aarch64.cc > +++ b/gcc/config/aarch64/aarch64.cc > @@ -2466,7 +2466,7 @@ aarch64_noce_conversion_profitable_p (rtx_insn *seq, > most cases. */ > if (if_info->speed_p) > { > - unsigned cost = seq_cost (seq, true); > + unsigned cost = noce_parallel_seq_cost (seq, true); > return cost <= if_info->max_seq_cost; > } > > diff --git a/gcc/ifcvt.cc b/gcc/ifcvt.cc > index cd205ffdb9a..6c37b6bd359 100644 > --- a/gcc/ifcvt.cc > +++ b/gcc/ifcvt.cc > @@ -891,7 +891,7 @@ noce_dependency_level (noce_ready_map &ready, > 0.2 < ratio <= 0.4 0.91 percent > 0.0 < ratio <= 0.2 0.00 percent. */ > > -static unsigned int > +unsigned int > noce_parallel_seq_cost (rtx_insn *seq, bool speed_p) > { > unsigned int serial_cost = seq_cost (seq, speed_p); > diff --git a/gcc/ifcvt.h b/gcc/ifcvt.h > index 8347e0e8bc8..1ffd5bbb797 100644 > --- a/gcc/ifcvt.h > +++ b/gcc/ifcvt.h > @@ -138,4 +138,6 @@ struct noce_if_info > const char *transform_name; > }; > > +extern unsigned int noce_parallel_seq_cost (rtx_insn *, bool); > + > #endif /* GCC_IFCVT_H */ > diff --git a/gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-1.c > b/gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-1.c > new file mode 100644 > index 00000000000..74f6677fa29 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-1.c > @@ -0,0 +1,27 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O2 -mcpu=olympus -fdump-rtl-ce1" } */ > + > +void > +select_values (unsigned int n, const volatile unsigned long input[][3], > + volatile unsigned long output[][2]) > +{ > + for (unsigned int i = 0; i < n; ++i) > + { > + unsigned long c = input[i][0], x = input[i][1], y = input[i][2]; > + unsigned long a, b; > + if (c > 7) > + { > + a = x * 3 + y; > + b = 2; > + } > + else > + { > + a = x + 9; > + b = 3; > + } > + output[i][0] = a; > + output[i][1] = b; > + } > +} > + > +/* { dg-final { scan-rtl-dump-times "if-conversion succeeded through > noce_convert_multiple_sets" 1 "ce1" } } */ > diff --git a/gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-2.c > b/gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-2.c > new file mode 100644 > index 00000000000..be414b109d7 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-2.c > @@ -0,0 +1,34 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O2 -mcpu=olympus -fdump-rtl-ce1" } */ > + > +void > +select_values (unsigned int n, const volatile unsigned long input[][3], > + volatile unsigned long output[][2]) > +{ > + for (unsigned int i = 0; i < n; ++i) > + { > + unsigned long c = input[i][0], x = input[i][1], y = input[i][2]; > + unsigned long a, b; > + if (c > 7) > + { > + a = x + 9; > + a ^= y; > + a >>= 2; > + a += 5; > + a ^= y; > + a >>= 3; > + a += 13; > + a ^= y; > + b = 2; > + } > + else > + { > + a = x + 9; > + b = 3; > + } > + output[i][0] = a; > + output[i][1] = b; > + } > +} > + > +/* { dg-final { scan-rtl-dump-not "if-conversion succeeded" "ce1" } } */ > diff --git a/gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-3.c > b/gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-3.c > new file mode 100644 > index 00000000000..d861b108e75 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-3.c > @@ -0,0 +1,6 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O2 -mcpu=olympus > --param=max-rtl-if-conversion-unpredictable-cost=1 > --param=max-rtl-if-conversion-predictable-cost=1 -fdump-rtl-ce1" } */ > + > +#include "noce-parallel-cost-1.c" > + > +/* { dg-final { scan-rtl-dump-not "if-conversion succeeded" "ce1" } } */ > diff --git a/gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-4.c > b/gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-4.c > new file mode 100644 > index 00000000000..fac1f2eee3a > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-4.c > @@ -0,0 +1,6 @@ > +/* { dg-do compile } */ > +/* { dg-options "-Os -mcpu=olympus -fdump-rtl-ce1" } */ > + > +#include "noce-parallel-cost-1.c" > + > +/* { dg-final { scan-rtl-dump-times "if-conversion succeeded through > noce_convert_multiple_sets" 1 "ce1" } } */ > diff --git a/gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-5.c > b/gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-5.c > new file mode 100644 > index 00000000000..d2213a522f9 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-5.c > @@ -0,0 +1,6 @@ > +/* { dg-do compile } */ > +/* { dg-options "-Oz -mcpu=olympus -fdump-rtl-ce1" } */ > + > +#include "noce-parallel-cost-1.c" > + > +/* { dg-final { scan-rtl-dump-times "if-conversion succeeded through > noce_convert_multiple_sets" 1 "ce1" } } */ > -- > 2.54.0 (Apple Git-157) >
