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 v2:
- 1/2: renamed the modes and selectors of the <c, c> merge: inner for
the inner permute (@1), vc for its view-converted value (@0), op2 for
the inner permute's inputs, result for the outer permute, sel4/sel5
for the selectors (@4/@5, formerly sel0/sel1) and new_sel for the
merged selector (formerly sel2; its tree is new_vcst, formerly op0).
The comment above the pattern shows the optional VIEW_CONVERT_EXPR and
uses the same names.
- 2/2: the merged permute's type is the result type unless the
VIEW_CONVERT_EXPR changes the element type, in which case it is a
vector of op2's element type with the result's element count; it no
longer depends on comparing element counts.
- No other changes.
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 | 91 +++--
.../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, 839 insertions(+), 26 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