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: packed integer basic arithmetic for x64 #10147

Merged

Conversation

MarinPostma
Copy link
Contributor

@MarinPostma MarinPostma commented Jan 29, 2025

implements the following instructions for winch x64:

  • i8x16.add
  • i8x16.add_sat_u
  • i8x16.add_sat_s
  • i16x8.add
  • i16x8.add_sat_u
  • i16x8.add_sat_s
  • i32x4.add
  • i64x2.add
  • i8x16.sub
  • i8x16.sub_sat_u
  • i8x16.sub_sat_s
  • i16x8.sub
  • i16x8.sub_sat_u
  • i16x8.sub_sat_s
  • i32x4.sub
  • i64x2.sub
  • i16x8.mul
  • i32x4.mul
  • i64x2.mul

#8093

@MarinPostma MarinPostma requested review from a team as code owners January 29, 2025 13:03
@MarinPostma MarinPostma requested review from fitzgen and removed request for a team January 29, 2025 13:03

/// Perform a vector add between `lsh` and `rhs`, placing the result in `dst`, where each lane
/// is interpreted to be `size` long.
fn v128_add(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

naming-wise, I'm completely sure what to call those. Maybe vector_add is more appropriate?

Copy link
Member

Choose a reason for hiding this comment

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

I think the naming is fine here, as far as I can tell, we don't have any other vector naming convention.

@saulecabrera
Copy link
Member

I can take this review.

@saulecabrera saulecabrera requested review from saulecabrera and removed request for a team and fitzgen January 29, 2025 17:19
Comment on lines 1751 to 1755
let mul_avx512 = |this: &mut Self, op| {
this.ensure_has_avx512vl()?;
this.ensure_has_avx512dq()?;
this.asm.xmm_rm_rvex3(op, lhs, rhs, dst);
Ok(())
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should make this a hard requirement, given that our baseline is AVX.

Given that Intel suggests that there's no penalty on mixing AVX with AVX512 instructions , we could emit AVX512 if they are available, however in case they aren't we still need to emit a fallback to avoid bumping our baseline for this operation. For reference: https://github.com/bytecodealliance/wasmtime/blob/main/cranelift/codegen/src/isa/x64/lower.isle#L1121

Copy link
Contributor Author

Choose a reason for hiding this comment

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

my bad, I misunderstood your DM about what we expected to support. I have ported cranelift fallback implementation.

Copy link
Contributor Author

@MarinPostma MarinPostma Jan 31, 2025

Choose a reason for hiding this comment

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

hold on I just found a bug

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed


/// Perform a vector add between `lsh` and `rhs`, placing the result in `dst`, where each lane
/// is interpreted to be `size` long.
fn v128_add(
Copy link
Member

Choose a reason for hiding this comment

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

I think the naming is fine here, as far as I can tell, we don't have any other vector naming convention.

@MarinPostma MarinPostma force-pushed the packed-integer-arithmetic branch 5 times, most recently from 8e99df3 to 6d9af62 Compare January 31, 2025 18:01
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.

LGTM, thanks!

@saulecabrera saulecabrera added this pull request to the merge queue Feb 3, 2025
Merged via the queue into bytecodealliance:main with commit 70c93c6 Feb 3, 2025
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants