Hi,

This patch series improves SLP reduction vectorization in two areas:

1. **IFN commutative operand swap**: Extends the existing commutative swap
   logic to internal functions like .COND_ADD. If-conversion can generate
   COND_ADD with reduction operands at different positions (arg1 vs arg2),
   which previously caused SLP rejection. The fix uses 
first_commutative_argument()
   to recognize and swap IFN operands when needed.

2. **Single-lane SLP fallback**: Moves the SLP discovery limit check to only
   guard chain analysis, allowing single-lane reductions to vectorize even
   when the limit is exhausted. This prevents missed optimizations in loops
   with many independent reductions.

For 731.astcenc_r (SPEC 2026) single-copy:
- EMR   : +7.1% (patch 1), +3.8% (patch 2) → ~11% total
- Znver5: +2.5% (patch 1), +1.4% (patch 2) → ~3.9% total

No regressions observed in other benchmarks.

Bootstrapped and tested on x86_64-linux-gnu. OK for trunk?


Thanks,
Lili.


Lili Cui (2):
  tree-optimization/vect: Allow commutative operand swap for IFN in SLP
    reduction
  tree-optimization/vect: Allow single-lane SLP fallback when limit is
    exhausted

 gcc/testsuite/gcc.dg/vect/slp-reduc-15.c | 81 ++++++++++++++++++++++++
 gcc/tree-vect-slp.cc                     | 17 +++--
 2 files changed, 92 insertions(+), 6 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/vect/slp-reduc-15.c

-- 
2.34.1

Reply via email to