This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] SIMD shifts
ClosedPublic

Authored by tlively on Sep 10 2018, 6:47 PM.

Details

Summary

Implement shifts of vectors by i32. Since LLVM defines shifts as
binary operations between two vectors, this involves pattern matching
on splatted shift operands. For v2i64 shifts any i32 shift operands
have to be zero extended in the input and any i64 shift operands have
to be wrapped in the output. Depends on D52007.

Diff Detail

Repository
rL LLVM

Event Timeline

tlively created this revision.Sep 10 2018, 6:47 PM
tlively updated this revision to Diff 165190.Sep 12 2018, 6:18 PM
  • Rebased and fixed up on top of D52007
tlively updated this revision to Diff 165195.Sep 12 2018, 7:50 PM
  • Add encoding tests for shifts

Does this work when the first argument is not in a splat pattern as well? If so, maybe add a test case for that?

lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
130 ↗(On Diff #165195)

Maybe shift_amount or shift_amount_pat instead of pat to denote this is not the pattern for the whole instruction but for the shift amount operand?

Does this work when the first argument is not in a splat pattern as well? If so, maybe add a test case for that?

No, our shift is weird because it takes only a single shift amount to apply uniformly to all lanes rather than a vector of shift amounts. Currently LLVM shifts by non-splat vectors will fail in isel, but that's ok for now.

tlively updated this revision to Diff 165608.Sep 14 2018, 4:01 PM
  • Address comment and rebase to pick up neg
tlively marked an inline comment as done.Sep 14 2018, 4:01 PM

Oh, what I meant is, the right operand is created not with insertelement + shufflevector but with just a constant vector whose all elements are the same integer. My comment was not very accurate because I think I remember you included that constant pattern as a splat too. So I guess it would work, but having a test case for that wouldn't hurt.

tlively updated this revision to Diff 165616.Sep 14 2018, 5:29 PM
  • Add tests for shifting by constant vectors
aheejin accepted this revision.Sep 14 2018, 5:41 PM
This revision is now accepted and ready to land.Sep 14 2018, 5:41 PM
This revision was automatically updated to reflect the committed changes.