[AArch64] Optimize instruction selection for certain vector shuffles
authorMikhail Maltsev <mikhail.maltsev@arm.com>
Thu, 27 Aug 2020 10:06:45 +0000 (11:06 +0100)
committerMikhail Maltsev <mikhail.maltsev@arm.com>
Thu, 27 Aug 2020 10:06:49 +0000 (11:06 +0100)
commit23d5e93f342e168b59838476abc0e03853609617
tree8257d07045e02d09cc77c7b98a0c5f50664e01e1
parent8191603dc42a1e2631996aae7d24569fbd90c52c
[AArch64] Optimize instruction selection for certain vector shuffles

This patch adds code to recognize vector shuffles which can be
represented as VDUP (splat) of a vector lane with of a different
(wider) type than the original vector lane type.

For example:
    shufflevector <4 x i16> %v, <4 x i16> undef, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
is essentially:
    shufflevector <2 x i32> %v, <2 x i32> undef, <2 x i32> <i32 0, i32 0>

Such patterns are generated by the SelectionDAG machinery in some cases
(see DAGCombiner::visitBITCAST in DAGCombiner.cpp, the "Remove double
bitcasts from shuffles" part).

Reviewed By: dmgreen

Differential Revision: https://reviews.llvm.org/D86225
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/test/CodeGen/AArch64/arm64-neon-2velem.ll
llvm/test/CodeGen/AArch64/arm64-vext_reverse.ll
llvm/test/CodeGen/AArch64/neon-extract.ll
llvm/test/CodeGen/AArch64/neon-wide-splat.ll [new file with mode: 0644]
llvm/test/CodeGen/AArch64/vecreduce-fmax-legalization-nan.ll