Skip to content

Conversation

rahulchaphalkar
Copy link
Contributor

Converts div instructions to new assembler. Remove old div impl from codegen for SSE variants, not Vex variants.

@rahulchaphalkar rahulchaphalkar requested a review from a team as a code owner May 28, 2025 18:47
@rahulchaphalkar rahulchaphalkar requested review from abrown and removed request for a team May 28, 2025 18:47
@github-actions github-actions bot added cranelift Issues related to the Cranelift code generator cranelift:area:x64 Issues related to x64 codegen winch Winch issues or pull requests labels May 28, 2025
Copy link

Subscribe to Label Action

cc @saulecabrera

This issue or pull request has been labeled: "cranelift", "cranelift:area:x64", "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.

@rahulchaphalkar
Copy link
Contributor Author

rahulchaphalkar commented May 28, 2025

Seem to be unrelated connection errors in CI like -

 Err:16 http://archive.ubuntu.com/ubuntu xenial/main amd64 libmpc3 amd64 1.0.3-1
#6 823.0   Could not connect to archive.ubuntu.com:80 (91.189.91.81), connection timed out [IP: 91.189.91.81 80]

Edit - They went away, now passes all tests

@rahulchaphalkar
Copy link
Contributor Author

@alexcrichton is this good to go?

Copy link
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

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

Oh oops, my bad!

@alexcrichton alexcrichton added this pull request to the merge queue Jun 4, 2025
Copy link
Member

@abrown abrown left a comment

Choose a reason for hiding this comment

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

This looks almost good to go; can you update the few locations I pointed out before I merge?

Comment on lines +22 to +23
inst("vdivss", fmt("B", [rw(xmm1), r(xmm2), r(xmm_m32)]), vex(L128)._f3()._0f().op(0x5E).r(), _64b | compat | avx),
inst("vdivsd", fmt("B", [rw(xmm1), r(xmm2), r(xmm_m64)]), vex(L128)._f2()._0f().op(0x5E).r(), _64b | compat | avx),
Copy link
Member

Choose a reason for hiding this comment

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

Just looking at the manual and, though this all will boil down to the same thing, I think we should be more pedantic and write:

Suggested change
inst("vdivss", fmt("B", [rw(xmm1), r(xmm2), r(xmm_m32)]), vex(L128)._f3()._0f().op(0x5E).r(), _64b | compat | avx),
inst("vdivsd", fmt("B", [rw(xmm1), r(xmm2), r(xmm_m64)]), vex(L128)._f2()._0f().op(0x5E).r(), _64b | compat | avx),
inst("vdivss", fmt("B", [rw(xmm1), r(xmm2), r(xmm_m32)]), vex(LIG)._f3()._0f().wig().op(0x5E).r(), _64b | compat | avx),
inst("vdivsd", fmt("B", [rw(xmm1), r(xmm2), r(xmm_m64)]), vex(LIG)._f2()._0f().wig().op(0x5E).r(), _64b | compat | avx),

(And this probably means other VEX instructions should get checked but we don't have to do that in this PR).

Comment on lines +20 to +21
inst("vdivps", fmt("B", [rw(xmm1), r(xmm2), r(xmm_m128)]), vex(L128)._0f().op(0x5E).r(), _64b | compat | avx),
inst("vdivpd", fmt("B", [rw(xmm1), r(xmm2), r(xmm_m128)]), vex(L128)._66()._0f().op(0x5E).r(), _64b | compat | avx),
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
inst("vdivps", fmt("B", [rw(xmm1), r(xmm2), r(xmm_m128)]), vex(L128)._0f().op(0x5E).r(), _64b | compat | avx),
inst("vdivpd", fmt("B", [rw(xmm1), r(xmm2), r(xmm_m128)]), vex(L128)._66()._0f().op(0x5E).r(), _64b | compat | avx),
inst("vdivps", fmt("B", [rw(xmm1), r(xmm2), r(xmm_m128)]), vex(L128)._0f().wig().op(0x5E).r(), _64b | compat | avx),
inst("vdivpd", fmt("B", [rw(xmm1), r(xmm2), r(xmm_m128)]), vex(L128)._66().wig()._0f().op(0x5E).r(), _64b | compat | avx),

Comment on lines 3582 to +3583
(rule (x64_divsd src1 src2)
(xmm_rm_r_unaligned (SseOpcode.Divsd) src1 src2))
(x64_divsd_a src1 src2))
Copy link
Member

Choose a reason for hiding this comment

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

A nit to add the rule priority and, in these very short cases, fit it on a single line:

(rule 0 (x64_divsd src1 src2) x64_divsd_a src1 src2))

Comment on lines +1 to +2
use crate::dsl::{Feature::*, Inst, Location::*, VexLength::*, align};
use crate::dsl::{fmt, implicit, inst, r, rex, rw, vex};
Copy link
Member

Choose a reason for hiding this comment

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

More nits:

Suggested change
use crate::dsl::{Feature::*, Inst, Location::*, VexLength::*, align};
use crate::dsl::{fmt, implicit, inst, r, rex, rw, vex};
use crate::dsl::{Feature::*, Inst, Location::*, VexLength::*};
use crate::dsl::{align, fmt, implicit, inst, r, rex, rw, vex};

@abrown
Copy link
Member

abrown commented Jun 4, 2025

Oops, looks like @alexcrichton and I raced; we can fix these nits later!

Merged via the queue into bytecodealliance:main with commit 7338ecf Jun 4, 2025
160 checks passed
abrown added a commit to abrown/wasmtime that referenced this pull request Jun 6, 2025
Some final review comments went unaddressed in bytecodealliance#10855 that this change
resolve, primarily using `LIG` for non-vector definitions. I was going
to add `.wig()` everywhere but, after thinking about it, it _is_ the
default value for `vex()` and leaving it out reduces the amount of
information one has to parse. This also cleans up a few extra lines I
saw lying around.
github-merge-queue bot pushed a commit that referenced this pull request Jun 6, 2025
Some final review comments went unaddressed in #10855 that this change
resolve, primarily using `LIG` for non-vector definitions. I was going
to add `.wig()` everywhere but, after thinking about it, it _is_ the
default value for `vex()` and leaving it out reduces the amount of
information one has to parse. This also cleans up a few extra lines I
saw lying around.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cranelift:area:x64 Issues related to x64 codegen cranelift Issues related to the Cranelift code generator winch Winch issues or pull requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants