-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
ISLE: aarch64: fix narrow sdiv on intmin/-1 #9541
Conversation
…e checking for intmin Co-authored-by: Michael McLoughlin <[email protected]>
;; instructions. | ||
(decl diff_from_32 (Type) u8) | ||
(rule (diff_from_32 $I8) 24) | ||
(rule (diff_from_32 $I16) 16) |
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 added this because this same pattern is used enough that a helper seems warranted (cls
, clz
, bitrev
) but saving changing those for another PR.
@@ -3664,24 +3670,18 @@ | |||
|
|||
;; Check for signed overflow. The only case is min_value / -1. | |||
;; The following checks must be done in 32-bit or 64-bit, depending | |||
;; on the input type. | |||
(spec (trap_if_div_overflow ty 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.
This spec is now stale, but the changes needed to verify the code correctly are ones we still need to upstream. Just removing for now?
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.
Sure -- no problem to re-add this when the rest is upstreamed.
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.
Looks great, thanks!
@@ -3664,24 +3670,18 @@ | |||
|
|||
;; Check for signed overflow. The only case is min_value / -1. | |||
;; The following checks must be done in 32-bit or 64-bit, depending | |||
;; on the input type. | |||
(spec (trap_if_div_overflow ty 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.
Sure -- no problem to re-add this when the rest is upstreamed.
* Fix a missing trap on narrow sdiv of intmin/-1 by left-shifting before checking for intmin Co-authored-by: Michael McLoughlin <[email protected]> * Remove non-upstreamed verifier attributes --------- Co-authored-by: Michael McLoughlin <[email protected]>
Fixes #9537
Clif's semantics (inherited from Wasm) specify are that divides should trap on
intmin/-1
. The manual check forintmin
in this case in ISLE is to add 1 to the dividend and check for overflow, however, the rule was not previously catching that an 8- or 16-bitintmin - 1
does not overflow with a 32-bit ARM instruction. This PR adds a left-shift of the dividend before feeding into theintmin
check, such that e.g. 0x00000080 is checked as 0x80000000. A ported version of this has been verified as correct by our prototype.Note this adds 1 additional instruction (
lsl
) in the 8- and 16-bit cases ofsdiv
. An alternative would be to check against hard-coded constants for those cases, but we think this would require adding a new conditional compare to theaarch64
assembler.This PR also adds a file test for the new instruction sequence.