aarch64: Add more vec_combine patterns
authorRichard Sandiford <richard.sandiford@arm.com>
Wed, 9 Feb 2022 16:57:05 +0000 (16:57 +0000)
committerRichard Sandiford <richard.sandiford@arm.com>
Wed, 9 Feb 2022 16:57:05 +0000 (16:57 +0000)
commit85ac2fe44fd4acf8350dd74ccb003a2050baad2a
treebb28b1b1f8c19ae2ca9f34d26630784e34d122b4
parentaeef5c57f161ad0258c5ab066ade2274bef3271a
aarch64: Add more vec_combine patterns

vec_combine is really one instruction on aarch64, provided that
the lowpart element is in the same register as the destination
vector.  This patch adds patterns for that.

The patch fixes a regression from GCC 8.  Before the patch:

int64x2_t s64q_1(int64_t a0, int64_t a1) {
  if (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
    return (int64x2_t) { a1, a0 };
  else
    return (int64x2_t) { a0, a1 };
}

generated:

        fmov    d0, x0
        ins     v0.d[1], x1
        ins     v0.d[1], x1
        ret

whereas GCC 8 generated the more respectable:

        dup     v0.2d, x0
        ins     v0.d[1], x1
        ret

gcc/
* config/aarch64/predicates.md (aarch64_reg_or_mem_pair_operand):
New predicate.
* config/aarch64/aarch64-simd.md (*aarch64_combine_internal<mode>)
(*aarch64_combine_internal_be<mode>): New patterns.

gcc/testsuite/
* gcc.target/aarch64/vec-init-9.c: New test.
* gcc.target/aarch64/vec-init-10.c: Likewise.
* gcc.target/aarch64/vec-init-11.c: Likewise.
gcc/config/aarch64/aarch64-simd.md
gcc/config/aarch64/predicates.md
gcc/testsuite/gcc.target/aarch64/vec-init-10.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/vec-init-11.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/vec-init-9.c [new file with mode: 0644]