[PATCH] D66983: [WebAssembly] Add wasm-specific vector shuffle builtin and intrinsic

Dan Gohman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 30 16:51:23 PDT 2019


sunfish added a comment.

In D66983#1651981 <https://reviews.llvm.org/D66983#1651981>, @craig.topper wrote:

> DAG combine is supposed to check with TargetLowering::isShuffleMaskLegal.


In @tlively's example, it is DAGCombine, and it does check isShuffleMaskLegal. However for wasm, it appears that's not enough -- in wasm, all shuffle masks are legal, because you can do any shuffle in a single wasm instruction. This makes it tricky, because the user here is aiming for an x86-like cost model, but the LLVM wasm backend doesn't have any x86-specific knowledge, so it just tells DAGCombine to form any shuffle it sees fit.

I wonder if it would make sense to introduce a counterpart to isShuffleMaskLegal, which instead of returning a bool returned a cost value. And then, we could teach the wasm backend about certain shuffle patterns which are known to be fast across multiple architectures. Then we could teach DAGComine to check whether the new shuffle it wants to create is actually cheaper than the one it's replacing. Thoughts?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66983/new/

https://reviews.llvm.org/D66983





More information about the llvm-commits mailing list