[PATCH] D83537: [WebAssembly] Use ISD::SPLAT_VECTOR for splats

Thomas Lively via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 10 00:27:16 PDT 2020


tlively created this revision.
tlively added reviewers: aheejin, dschuff.
Herald added subscribers: llvm-commits, sunfish, hiraditya, jgravelle-google, sbc100.
Herald added a project: LLVM.

This patch legalizes ISD::SPLAT_VECTOR to enable the generic DAG
combines that create splat_vector nodes. This simplifies some ISel
patterns, although ISD::isBuildVectorAllOnes has to be extended to
recognize splat_vectors to keep the vnot pattern fragment working.

The AddedComplexity for splats is also removed so that we no longer
prefer constant splats over v128.const instructions. This is
consistent with the instruction preferences used in BUILD_VECTOR
lowering and reduces the instruction count in many tests.

There is a small regression in that insert_vector_elts into undef
vectors at constant indices that could previously have been turned
into swizzles can no longer be simplified that way because those nodes
are combined to splat_vector nodes instead of BUILD_VECTOR nodes. This
change includes a custom target combine meant to fix this, but
unfortunately the generic combine gets precedence over the custom
combine. Fixing this is left as future work, and the custom combine is
kept because it is still useful in the non-constant index case. See
@swizzle_one_i8x16 and @swizzle_one_var_i8x16 in simd-build-vector.ll
for details.

The motivation for this change is that follow-on patches will
introduce new combines that will greatly improve codegen for splatted
vector shift values but rely on splats having no undef lanes. Unlike a
splatting build_vector, a splat_vector node never has undef lanes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83537

Files:
  llvm/include/llvm/Target/TargetSelectionDAG.td
  llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISD.def
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
  llvm/test/CodeGen/WebAssembly/simd-arith.ll
  llvm/test/CodeGen/WebAssembly/simd-build-vector.ll
  llvm/test/CodeGen/WebAssembly/simd-load-splat.ll
  llvm/test/CodeGen/WebAssembly/simd.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83537.276934.patch
Type: text/x-patch
Size: 27977 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200710/dc4bc1ee/attachment.bin>


More information about the llvm-commits mailing list