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

Optimise Int32.unsigned_to_int on 64-bit #10244

Merged
merged 1 commit into from
Mar 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ Working version
- #10228: Better code-generation for inlined comparisons
(Stephen Dolan, review by Alain Frisch and Xavier Leroy)

- #10244: Optimise Int32.unsigned_to_int
(Fabian Hemmer, review by Stephen Dolan and Xavier Leroy)

### Standard library:

- #9533: Added String.starts_with and String.ends_with.
Expand Down
4 changes: 2 additions & 2 deletions stdlib/int32.ml
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ let unsigned_to_int =
None
| 64 ->
(* So that it compiles in 32-bit *)
let move = int_of_string "0x1_0000_0000" in
fun n -> let i = to_int n in Some (if i < 0 then i + move else i)
let mask = 0xFFFF lsl 16 lor 0xFFFF in
fun n -> Some (to_int n land mask)
| _ ->
assert false

Expand Down