Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Winch: Add SIMD load and extend and load and splat instructions for x64 #9950

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jeffcharles
Copy link
Contributor

Part of #8093. Adds support on x64 with AVX2 for:

  • v128.load8x8_s
  • v128.load8x8_u
  • v128.load16x4_s
  • v128.load16x4_u
  • v128.load32x2_s
  • v128.load32x2_u
  • v128.load8_splat
  • v128.load16_splat
  • v128.load32_splat
  • v128.load64_splat

I've changed wasm_load on the macroassemblers to take a LoadKind instead of Option<ExtendKind> to model the additional vector operations (vector extends and splats), but I'm open to changing that to a different abstraction.

@jeffcharles jeffcharles requested review from a team as code owners January 8, 2025 15:57
@jeffcharles jeffcharles requested review from abrown and pchickey and removed request for a team January 8, 2025 15:57
@saulecabrera
Copy link
Member

I can take this review.

@saulecabrera saulecabrera self-requested a review January 8, 2025 16:14
@github-actions github-actions bot added the winch Winch issues or pull requests label Jan 8, 2025
Copy link

github-actions bot commented Jan 8, 2025

Subscribe to Label Action

cc @saulecabrera

This issue or pull request has been labeled: "winch"

Thus the following users have been cc'd because of the following labels:

  • saulecabrera: winch

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

Copy link
Member

@saulecabrera saulecabrera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! Left some comments inline.

self.asm.uload(src, dst, size);
match kind {
LoadKind::None => self.asm.uload(src, dst, size),
LoadKind::Splat => todo!(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you return an error here instead of panicking? I've done a refactoring across the compiler to ensure that panics are minimal, particularly for unimplemented/unsupported features. This ensures that we can can successfully run spec tests even when there's partial support for Wasm proposals.

Perhaps we can introduce a new Unimplemeted* enum entry here https://github.com/bytecodealliance/wasmtime/blob/main/winch/codegen/src/codegen/error.rs#L7, something around the lines of UnimplementedLoadKind

Comment on lines +485 to +492
let op = match ext {
VectorExtendKind::V128Extend8x8S => SseOpcode::Pmovsxbw,
VectorExtendKind::V128Extend8x8U => SseOpcode::Pmovzxbw,
VectorExtendKind::V128Extend16x4S => SseOpcode::Pmovsxwd,
VectorExtendKind::V128Extend16x4U => SseOpcode::Pmovzxwd,
VectorExtendKind::V128Extend32x2S => SseOpcode::Pmovsxdq,
VectorExtendKind::V128Extend32x2U => SseOpcode::Pmovzxdq,
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that we're starting with avx2 as our baseline, I wonder if we should emit the vpmov* variants here.

/// Kinds of behavior supported by Wasm loads.
pub(crate) enum LoadKind {
/// Do not extend or splat.
None,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: can we remove this enum entry and keep Option<LoadKind> instead? Or where you envisioning this approach to be easier to consume in the callee as opposed to using an Option?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
winch Winch issues or pull requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants