[DAGCombine] Fold Splat(bitcast(buildvector(x,..))) to splat(x)
authorDavid Green <david.green@arm.com>
Mon, 12 Dec 2022 08:35:43 +0000 (08:35 +0000)
committerDavid Green <david.green@arm.com>
Mon, 12 Dec 2022 08:35:43 +0000 (08:35 +0000)
commitfd716925eca2a65c79a4375fb46151816afc1809
tree03e9ec468ccb764b8e59787d3bb0b3743da6820c
parent8005332835246c54a4a6b026eede930ed559deb4
[DAGCombine] Fold Splat(bitcast(buildvector(x,..))) to splat(x)

This adds a fold which teaches the backend to fold
splat(bitcast(buildvector(x,..))) or
splat(bitcast(scalar_to_vector(x))) to a single splat.

This only handles lane 0 splats, which are only valid under LE, and
needs to be a little careful with the types it creates for the new
buildvector.

Differential Revision: https://reviews.llvm.org/D139611
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/AArch64/arm64-dup.ll
llvm/test/CodeGen/AArch64/arm64-neon-3vdiff.ll
llvm/test/CodeGen/Thumb2/mve-vdup.ll
llvm/test/CodeGen/WebAssembly/simd-shuffle-bitcast.ll
llvm/test/CodeGen/X86/vector-shuffle-mmx.ll