This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Add builtin and intrinsic for v8x16.swizzle
ClosedPublic

Authored by tlively on Oct 4 2019, 6:01 PM.

Details

Summary

This clang builtin and corresponding LLVM intrinsic are necessary to
expose the exact semantics of the underlying WebAssembly instruction
to users. LLVM produces a poison value if the dynamic swizzle indices
are greater than the vector size, but the WebAssembly instruction sets
the corresponding output lane to zero. Users who depend on this
behavior can safely use this builtin.

Depends on D68527.

Diff Detail

Event Timeline

tlively created this revision.Oct 4 2019, 6:01 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptOct 4 2019, 6:01 PM
aheejin accepted this revision.Oct 8 2019, 8:50 AM

LLVM produces a poison value if the dynamic swizzle indices are greater than the vector size, but the WebAssembly instruction sets the corresponding output lane to zero.

Where do we set those undef or poison lanes to zero?

clang/include/clang/Basic/BuiltinsWebAssembly.def
63

Is the second indices vector always v8x16 too?

This revision is now accepted and ready to land.Oct 8 2019, 8:50 AM
tlively marked an inline comment as done.Oct 8 2019, 11:13 AM

LLVM produces a poison value if the dynamic swizzle indices are greater than the vector size, but the WebAssembly instruction sets the corresponding output lane to zero.

Where do we set those undef or poison lanes to zero?

We don't do that in the toolchain. It's the runtime semantics implemented in engines that set the output lanes to zero.

clang/include/clang/Basic/BuiltinsWebAssembly.def
63

Yes, that's the only version of swizzling we have for now.

This revision was automatically updated to reflect the committed changes.