This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Implement TargetLowering hooks for vectors
Changes PlannedPublic

Authored by tlively on Nov 8 2018, 5:37 PM.

Details

Reviewers
aheejin
dschuff

Diff Detail

Event Timeline

tlively created this revision.Nov 8 2018, 5:37 PM
sbc100 added a comment.Nov 8 2018, 5:42 PM

Didn't effect any tests? Presumably that means we are missing some?

Didn't effect any tests? Presumably that means we are missing some?

Maybe. These functions are all called by target-independent optimizations that presumably are tested elsewhere. shouldExpandBuildVectorWithShuffles is actually never called right now, since we never expand build_vectors (but I'm considering changing that).

sunfish added inline comments.Nov 11 2018, 6:45 PM
lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
513

While shuffles are quite large, the alternative is to store each element to the stack, one at a time, and then load them back as a vector. This will often be larger than the corresponding shuffle sequence. And it'll very likely be slower.

I think we can have test for each of these functions; each selection should affect code generation of some constructs. For example, for storeOfVectorConstantIsCheap, we can have a test that .ll code that stores a vector value to memory will generate a single vector store rather than n scalar stores. Searching for the usages of each function in llvm code might help I think.

lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
526

The explanation of this function says:

Return true if inserting a scalar into a variable element of an undef vector is more efficiently handled by splatting the scalar instead.

I'm not 100% sure what this means, but to me this sounds like, if you want to insert a single element to an undef vector, it is better to just do splat then inserting a single element.

  1. Is my interpretation correct?
  2. If so, what should other undef elements be initialized with?
  3. Don't we have replace_lane too? Why is splat faster than replace_lane?

And while investigating current behaviors related to this, I filed a bug. I might be mistaken, so please let me know then.

529

Maybe it's better to state that wasm SIMD shift instruction only takes scalar shift amounts, so if it's not a scalar we need an expensive sequence of code.

tlively planned changes to this revision.Jan 9 2019, 4:06 PM

This is not being actively worked on right now.