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

Fix mulx #531

Merged
merged 15 commits into from
Jul 19, 2023
Merged

Fix mulx #531

merged 15 commits into from
Jul 19, 2023

Conversation

bgregoir
Copy link
Contributor

This should fix the semantic of the MULX instruction.
It introduces the operator
(lo, hi) = MULX_lo_hi (x,y); (this corresponds to the mulx of x86)
the previous MULX operator is then compiled to
(hi, lo) = MULX (x,y);
---->
(lo, hi) = MULX_lo_hi (x,y);
It also introduces
hi = MULX_hi (x, y) which is compiled to
(hi,hi) = MULX_lo_hi(x,y)
This is the only way to generate a mulx instruction where the two destination are
equals.

Comment on lines 126 to 127
let '(hi,lo) := wumul v1 v2 in
ok hi.
Copy link
Member

Choose a reason for hiding this comment

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

What about using wmulhu instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will do that

proofs/compiler/x86_instr_decl.v Outdated Show resolved Hide resolved
proofs/compiler/x86_params_proof.v Outdated Show resolved Hide resolved
proofs/compiler/x86_params_proof.v Outdated Show resolved Hide resolved
proofs/compiler/x86_params_proof.v Outdated Show resolved Hide resolved
proofs/compiler/x86_params_proof.v Outdated Show resolved Hide resolved
proofs/compiler/x86_extra.v Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@basavesh
Copy link
Collaborator

Dumb fuzzer is happy with the fix. The bug used to trigger with just one single input. I ran it for 10min or so and I don't see any crashes. Thanks!

bgregoir and others added 9 commits July 19, 2023 14:31
Co-authored-by: Vincent Laporte <vbgl@users.noreply.github.com>
Co-authored-by: Vincent Laporte <vbgl@users.noreply.github.com>
Co-authored-by: Vincent Laporte <vbgl@users.noreply.github.com>
Co-authored-by: Vincent Laporte <vbgl@users.noreply.github.com>
Co-authored-by: Vincent Laporte <vbgl@users.noreply.github.com>
Co-authored-by: Vincent Laporte <vbgl@users.noreply.github.com>
Co-authored-by: Vincent Laporte <vbgl@users.noreply.github.com>
Co-authored-by: Vincent Laporte <vbgl@users.noreply.github.com>
CHANGELOG.md Outdated
@@ -25,8 +25,16 @@
- Notation for string literals; there is no implicit zero terminator;
([PR #517](https://github.com/jasmin-lang/jasmin/pull/517)).

- Add the instruction `MULX_hi`,
`hi = #MULX(x, y);` is equivalent to `hi, _ = #MULX(x, y);`
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
`hi = #MULX(x, y);` is equivalent to `hi, _ = #MULX(x, y);`
`hi = #MULX_hi(x, y);` is equivalent to `hi, _ = #MULX(x, y);`

Comment on lines 11 to 22
/* FAIL
export fn test_ (reg u64 x, reg u64 y) -> reg u64 {
reg u64 hi, lo, z1, z2;
x = x;
(lo,lo) = #MULX(x, y);
z1 = lo;
z1 = lo << 1;
z1 += lo;
return z1;

}
*/
Copy link
Member

Choose a reason for hiding this comment

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

What’s the purpose of this comment?

Comment on lines 43 to 55
/* success, but mulx still use 2 differents registers for destination */
/* But the extraction fail */
/*
export fn test_lo_hi_ (reg u64 x, reg u64 y) -> reg u64 {
reg u64 hi, lo, z1, z2;
x = x;
(lo,lo) = #MULX_lo_hi(x, y);
z1 = lo;
z1 = z1 << 1;
z1 += lo;
return z1;
}
*/
Copy link
Member

Choose a reason for hiding this comment

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

Same question.

@vbgl vbgl merged commit 6b1ed0c into main Jul 19, 2023
@vbgl vbgl deleted the fix-mulx branch July 19, 2023 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect semantic computation for MULX when first and second argument are same
3 participants