-
Notifications
You must be signed in to change notification settings - Fork 56
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
Conversation
proofs/compiler/x86_extra.v
Outdated
let '(hi,lo) := wumul v1 v2 in | ||
ok hi. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will do that
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! |
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);` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`hi = #MULX(x, y);` is equivalent to `hi, _ = #MULX(x, y);` | |
`hi = #MULX_hi(x, y);` is equivalent to `hi, _ = #MULX(x, y);` |
/* 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; | ||
|
||
} | ||
*/ |
There was a problem hiding this comment.
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?
/* 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; | ||
} | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question.
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.