[WebAssembly] Optimize splats of bitcasted vectors
authorThomas Lively <tlively@google.com>
Fri, 15 May 2020 19:12:20 +0000 (12:12 -0700)
committerThomas Lively <tlively@google.com>
Fri, 15 May 2020 19:12:20 +0000 (12:12 -0700)
commit40af48101b1c65693dee289a960c381e0a993238
tree408e7a38f6ea7d161ffc92f57327fe64c6d81ce4
parent90af55d8a972b268d1b30feec8fb407ca856e110
[WebAssembly] Optimize splats of bitcasted vectors

Summary:
This new custom DAG combine fixes a codegen issue with the
wasm_simd128.h intrinsics. Clang lowers the

  return (v128_t)(__f32x4){__a, __a, __a, __a};

body of f32x4_splat to a splat shuffle of a bitcasted vector, as seen
in the new simd-shuffle-bitcast.ll test. The bitcast interfered with
the target-independent DAG combine that combines splat shuffles into
BUILD_VECTOR nodes, so this patch introduces a new custom DAG combine
to hoist the bitcast out of the shuffle, allowing the
target-independent combine to work as intended.

Reviewers: aheejin, dschuff

Subscribers: sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D80021
llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h
llvm/test/CodeGen/WebAssembly/simd-shuffle-bitcast.ll [new file with mode: 0644]