Patch 1 is the mode-query problem Richard asked to split out of v1.  It
has its own PR now since it has a visible effect by itself: with a
view-convert between the two permutes the pattern merges them even when
only the merged permute is unsupported, and the result is lowered
element by element (3 -> 13 instructions on x86_64 with SSE2).

Patch 2 is the fix for permutes whose inputs and results differ in
length, on top of that.

Bootstrapped and regtested on x86_64-pc-linux-gnu (-m32/-m64), no new 
regressions.

Changes since v1:
- Split the can_vec_perm_const_p mode queries of the <c, c> merge into
  their own patch (1/2, PR127882), with a testcase.
- 2/2: use sel0.nelts_per_input () for the merged selector.
- 2/2: the merged permute's mode is computed once (perm_mode) and the
  comments no longer talk about element types.
- 2/2: reworded the comment above the <c, c> pattern: a and b have the
  same length, c and d may each differ.
- 2/2: new test vec-perm-merge-wide-input-3.c covering all nine length
  combinations of a/c/d for the <c, c> merge (re the sel0[sel1[i]]
  question).
- Added Assisted-by: to both patches.

Igor Shevlyakov (2):
  match.pd: Fix mode queries of VEC_PERM merge through view-convert
    [PR127882]
  middle-end: Fix VEC_PERM_EXPR merges of different-length vectors
    [PR127862]

 gcc/match.pd                                  |  67 ++-
 .../torture/vec-perm-merge-wide-input-1.c     | 193 +++++++++
 .../torture/vec-perm-merge-wide-input-2.c     |  64 +++
 .../torture/vec-perm-merge-wide-input-3.c     | 382 ++++++++++++++++++
 .../gcc.target/aarch64/sve/pr127862.c         |  53 +++
 .../gcc.target/aarch64/sve/pr127862_run.c     |  46 +++
 gcc/testsuite/gcc.target/i386/pr127882.c      |  27 ++
 gcc/tree-ssa-forwprop.cc                      |   9 +
 8 files changed, 826 insertions(+), 15 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/torture/vec-perm-merge-wide-input-1.c
 create mode 100644 gcc/testsuite/gcc.dg/torture/vec-perm-merge-wide-input-2.c
 create mode 100644 gcc/testsuite/gcc.dg/torture/vec-perm-merge-wide-input-3.c
 create mode 100644 gcc/testsuite/gcc.target/aarch64/sve/pr127862.c
 create mode 100644 gcc/testsuite/gcc.target/aarch64/sve/pr127862_run.c
 create mode 100644 gcc/testsuite/gcc.target/i386/pr127882.c

-- 
2.56.0


Reply via email to