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

x64: Add support for the BMI2 mulx instruction #9248

Merged
merged 1 commit into from
Sep 13, 2024

Conversation

alexcrichton
Copy link
Member

This commit adds backend support for the mulx instruction in the BMI2 instruction set which supports arbitrary destination registers. This instruction also doesn't read/clobber flags so it can help pipeline instructions in niche situations.

This commit adds backend support for the `mulx` instruction in the BMI2
instruction set which supports arbitrary destination registers. This
instruction also doesn't read/clobber flags so it can help pipeline
instructions in niche situations.
@alexcrichton alexcrichton requested a review from a team as a code owner September 13, 2024 21:45
@alexcrichton alexcrichton requested review from fitzgen and removed request for a team September 13, 2024 21:45
@@ -2636,6 +2651,26 @@
(_ Unit (emit (MInst.Mul size signed src1 src2 dst_lo dst_hi))))
(value_gprs dst_lo dst_hi)))

;; Special case the `mulx` pattern with the BMI2 instruction set.
(rule 1 (x64_mul (ty_32_or_64 ty) $false 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.

Is there no imulx instruction for signed multiplication?

Copy link
Member Author

Choose a reason for hiding this comment

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

Alas not that I can find, just an unsigned variant. I think it's geared towards bignum libraries where most of the intermediate ops are unsigned ones.

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense, thanks for checking

@alexcrichton alexcrichton added this pull request to the merge queue Sep 13, 2024
Merged via the queue into bytecodealliance:main with commit 8f94133 Sep 13, 2024
69 checks passed
@alexcrichton alexcrichton deleted the x64-mulx branch September 13, 2024 22:15
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