My working unpac space for OCaml projects in development
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge opam/patches/ocaml_intrinsics_kernel

+5498
+5
vendor/opam/ocaml_intrinsics_kernel/.gitignore
··· 1 + _build 2 + *.install 3 + *.merlin 4 + _opam 5 +
+1
vendor/opam/ocaml_intrinsics_kernel/.ocamlformat
··· 1 + profile=janestreet
+67
vendor/opam/ocaml_intrinsics_kernel/CONTRIBUTING.md
··· 1 + This repository contains open source software that is developed and 2 + maintained by [Jane Street][js]. 3 + 4 + Contributions to this project are welcome and should be submitted via 5 + GitHub pull requests. 6 + 7 + Signing contributions 8 + --------------------- 9 + 10 + We require that you sign your contributions. Your signature certifies 11 + that you wrote the patch or otherwise have the right to pass it on as 12 + an open-source patch. The rules are pretty simple: if you can certify 13 + the below (from [developercertificate.org][dco]): 14 + 15 + ``` 16 + Developer Certificate of Origin 17 + Version 1.1 18 + 19 + Copyright (C) 2004, 2006 The Linux Foundation and its contributors. 20 + 1 Letterman Drive 21 + Suite D4700 22 + San Francisco, CA, 94129 23 + 24 + Everyone is permitted to copy and distribute verbatim copies of this 25 + license document, but changing it is not allowed. 26 + 27 + 28 + Developer's Certificate of Origin 1.1 29 + 30 + By making a contribution to this project, I certify that: 31 + 32 + (a) The contribution was created in whole or in part by me and I 33 + have the right to submit it under the open source license 34 + indicated in the file; or 35 + 36 + (b) The contribution is based upon previous work that, to the best 37 + of my knowledge, is covered under an appropriate open source 38 + license and I have the right under that license to submit that 39 + work with modifications, whether created in whole or in part 40 + by me, under the same open source license (unless I am 41 + permitted to submit under a different license), as indicated 42 + in the file; or 43 + 44 + (c) The contribution was provided directly to me by some other 45 + person who certified (a), (b) or (c) and I have not modified 46 + it. 47 + 48 + (d) I understand and agree that this project and the contribution 49 + are public and that a record of the contribution (including all 50 + personal information I submit with it, including my sign-off) is 51 + maintained indefinitely and may be redistributed consistent with 52 + this project or the open source license(s) involved. 53 + ``` 54 + 55 + Then you just add a line to every git commit message: 56 + 57 + ``` 58 + Signed-off-by: Joe Smith <joe.smith@email.com> 59 + ``` 60 + 61 + Use your real name (sorry, no pseudonyms or anonymous contributions.) 62 + 63 + If you set your `user.name` and `user.email` git configs, you can sign 64 + your commit automatically with git commit -s. 65 + 66 + [dco]: http://developercertificate.org/ 67 + [js]: https://opensource.janestreet.com/
+21
vendor/opam/ocaml_intrinsics_kernel/LICENSE.md
··· 1 + The MIT License 2 + 3 + Copyright (c) 2020--2025 Jane Street Group, LLC <opensource-contacts@janestreet.com> 4 + 5 + Permission is hereby granted, free of charge, to any person obtaining a copy 6 + of this software and associated documentation files (the "Software"), to deal 7 + in the Software without restriction, including without limitation the rights 8 + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 + copies of the Software, and to permit persons to whom the Software is 10 + furnished to do so, subject to the following conditions: 11 + 12 + The above copyright notice and this permission notice shall be included in all 13 + copies or substantial portions of the Software. 14 + 15 + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 + SOFTWARE.
+17
vendor/opam/ocaml_intrinsics_kernel/Makefile
··· 1 + INSTALL_ARGS := $(if $(PREFIX),--prefix $(PREFIX),) 2 + 3 + default: 4 + dune build 5 + 6 + install: 7 + dune install $(INSTALL_ARGS) 8 + 9 + uninstall: 10 + dune uninstall $(INSTALL_ARGS) 11 + 12 + reinstall: uninstall install 13 + 14 + clean: 15 + dune clean 16 + 17 + .PHONY: default install uninstall reinstall clean
+12
vendor/opam/ocaml_intrinsics_kernel/README.md
··· 1 + ocaml_intrinsics_kernel - a library of intrinsics for OCaml 2 + =========================================================== 3 + 4 + 5 + The ocaml_intrinsics_kernel library provides an OCaml interface to operations 6 + that have dedicated hardware instructions on some micro-architectures. 7 + Currently, it provides the following operations: 8 + 9 + * conditional select 10 + 11 + See ocaml_intrinsics for details. Unlike ocaml_intrinsics, ocaml_intrinsics_kernel 12 + can be used by programs compiled to javascript.
+168
vendor/opam/ocaml_intrinsics_kernel/bench/bench.ml
··· 1 + open! Base 2 + module I = Ocaml_intrinsics_kernel 3 + 4 + module%bench Overheads = struct 5 + (* Using [%bench_fun] to bind the input outside the benchmarked code actually has less 6 + overhead then using [%bench] naively. *) 7 + let%bench_fun "int overhead" = 8 + let n = Sys.opaque_identity (Random.int Int.max_value) in 9 + fun () -> Fn.id n 10 + ;; 11 + 12 + let%bench_fun "int64 overhead" = 13 + let n = Sys.opaque_identity (Random.int64 Int64.max_value) in 14 + fun () -> Fn.id n 15 + ;; 16 + 17 + let%bench_fun "int32 overhead" = 18 + let n = Sys.opaque_identity (Random.int32 Int32.max_value) in 19 + fun () -> Fn.id n 20 + ;; 21 + 22 + let%bench_fun "nativeint overhead" = 23 + let n = Sys.opaque_identity (Random.nativeint Nativeint.max_value) in 24 + fun () -> Fn.id n 25 + ;; 26 + end 27 + 28 + module%bench Clz = struct 29 + (* ocaml_intrinsics library *) 30 + let%bench_fun "int_clz" = 31 + let n = Sys.opaque_identity (Random.int Int.max_value) in 32 + fun () -> I.Int.count_leading_zeros n 33 + ;; 34 + 35 + let%bench_fun "int_clz2" = 36 + let n = Sys.opaque_identity (Random.int Int.max_value) in 37 + fun () -> I.Int.count_leading_zeros2 n 38 + ;; 39 + 40 + let%bench_fun "int64_clz" = 41 + let n = Sys.opaque_identity (Random.int64 Int64.max_value) in 42 + fun () -> I.Int64.count_leading_zeros n 43 + ;; 44 + 45 + let%bench_fun "nativeint_clz" = 46 + let n = Sys.opaque_identity (Random.nativeint Nativeint.max_value) in 47 + fun () -> I.Nativeint.count_leading_zeros n 48 + ;; 49 + 50 + let%bench_fun "int32_clz" = 51 + let n = Sys.opaque_identity (Random.int32 Int32.max_value) in 52 + fun () -> I.Int32.count_leading_zeros n 53 + ;; 54 + 55 + (* Base *) 56 + let%bench_fun "base int_clz" = 57 + let n = Sys.opaque_identity (Random.int Int.max_value) in 58 + fun () -> Base.Int.clz n 59 + ;; 60 + 61 + let%bench_fun "base int64_clz" = 62 + let n = Sys.opaque_identity (Random.int64 Int64.max_value) in 63 + fun () -> Base.Int64.clz n 64 + ;; 65 + 66 + let%bench_fun "base nativeint_clz" = 67 + let n = Sys.opaque_identity (Random.nativeint Nativeint.max_value) in 68 + fun () -> Base.Nativeint.clz n 69 + ;; 70 + 71 + let%bench_fun "base int32_clz" = 72 + let n = Sys.opaque_identity (Random.int32 Int32.max_value) in 73 + fun () -> Base.Int32.clz n 74 + ;; 75 + end 76 + 77 + module%bench Ctz = struct 78 + (* ocaml_intrinsics library *) 79 + let%bench_fun "int_ctz" = 80 + let n = Sys.opaque_identity (Random.int Int.max_value) in 81 + fun () -> I.Int.count_trailing_zeros n 82 + ;; 83 + 84 + let%bench_fun "int64_ctz" = 85 + let n = Sys.opaque_identity (Random.int64 Int64.max_value) in 86 + fun () -> I.Int64.count_trailing_zeros n 87 + ;; 88 + 89 + let%bench_fun "nativeint_ctz" = 90 + let n = Sys.opaque_identity (Random.nativeint Nativeint.max_value) in 91 + fun () -> I.Nativeint.count_trailing_zeros n 92 + ;; 93 + 94 + let%bench_fun "int32_ctz" = 95 + let n = Sys.opaque_identity (Random.int32 Int32.max_value) in 96 + fun () -> I.Int32.count_trailing_zeros n 97 + ;; 98 + 99 + (* Base *) 100 + let%bench_fun "base int_ctz" = 101 + let n = Sys.opaque_identity (Random.int Int.max_value) in 102 + fun () -> Base.Int.ctz n 103 + ;; 104 + 105 + let%bench_fun "base int64_ctz" = 106 + let n = Sys.opaque_identity (Random.int64 Int64.max_value) in 107 + fun () -> Base.Int64.ctz n 108 + ;; 109 + 110 + let%bench_fun "base nativeint_ctz" = 111 + let n = Sys.opaque_identity (Random.nativeint Nativeint.max_value) in 112 + fun () -> Base.Nativeint.ctz n 113 + ;; 114 + 115 + let%bench_fun "base int32_ctz" = 116 + let n = Sys.opaque_identity (Random.int32 Int32.max_value) in 117 + fun () -> Base.Int32.ctz n 118 + ;; 119 + end 120 + 121 + module%bench Popcnt = struct 122 + (* ocaml_intrinsics library *) 123 + let%bench_fun "int_popcount" = 124 + let n = Sys.opaque_identity (Random.int Int.max_value) in 125 + fun () -> I.Int.count_set_bits n 126 + ;; 127 + 128 + let%bench_fun "int_popcount2" = 129 + let n = Sys.opaque_identity (Random.int Int.max_value) in 130 + fun () -> I.Int.count_set_bits2 n 131 + ;; 132 + 133 + let%bench_fun "int64_popcount" = 134 + let n = Sys.opaque_identity (Random.int64 Int64.max_value) in 135 + fun () -> I.Int64.count_set_bits n 136 + ;; 137 + 138 + let%bench_fun "nativeint_popcount" = 139 + let n = Sys.opaque_identity (Random.nativeint Nativeint.max_value) in 140 + fun () -> I.Nativeint.count_set_bits n 141 + ;; 142 + 143 + let%bench_fun "int32_popcount" = 144 + let n = Sys.opaque_identity (Random.int32 Int32.max_value) in 145 + fun () -> I.Int32.count_set_bits n 146 + ;; 147 + 148 + (* Base *) 149 + let%bench_fun "base int_popcount" = 150 + let n = Sys.opaque_identity (Random.int Int.max_value) in 151 + fun () -> Base.Int.popcount n 152 + ;; 153 + 154 + let%bench_fun "base int64_popcount" = 155 + let n = Sys.opaque_identity (Random.int64 Int64.max_value) in 156 + fun () -> Base.Int64.popcount n 157 + ;; 158 + 159 + let%bench_fun "base nativeint_popcount" = 160 + let n = Sys.opaque_identity (Random.nativeint Nativeint.max_value) in 161 + fun () -> Base.Nativeint.popcount n 162 + ;; 163 + 164 + let%bench_fun "base int32_popcount" = 165 + let n = Sys.opaque_identity (Random.int32 Int32.max_value) in 166 + fun () -> Base.Int32.popcount n 167 + ;; 168 + end
+1
vendor/opam/ocaml_intrinsics_kernel/bench/bench.mli
··· 1 + (*_ This signature is deliberately empty. *)
+6
vendor/opam/ocaml_intrinsics_kernel/bench/dune
··· 1 + (library 2 + (name ocaml_intrinsics_kernel_bench) 3 + (libraries ocaml_intrinsics_kernel ppx_bench.runtime-lib ppx_expect.runtime 4 + ppx_module_timer.runtime) 5 + (preprocess 6 + (pps ppx_jane)))
+1
vendor/opam/ocaml_intrinsics_kernel/bench/ocaml_intrinsics_kernel_bench.ml
··· 1 + module Bench = Bench
+1
vendor/opam/ocaml_intrinsics_kernel/dune-project
··· 1 + (lang dune 3.17)
+22
vendor/opam/ocaml_intrinsics_kernel/ocaml_intrinsics_kernel.opam
··· 1 + opam-version: "2.0" 2 + maintainer: "Jane Street developers" 3 + authors: ["Jane Street Group, LLC"] 4 + homepage: "https://github.com/janestreet/ocaml_intrinsics_kernel" 5 + bug-reports: "https://github.com/janestreet/ocaml_intrinsics_kernel/issues" 6 + dev-repo: "git+https://github.com/janestreet/ocaml_intrinsics_kernel.git" 7 + doc: "https://ocaml.janestreet.com/ocaml-core/latest/doc/ocaml_intrinsics_kernel/index.html" 8 + license: "MIT" 9 + build: [ 10 + ["dune" "build" "-p" name "-j" jobs] 11 + ] 12 + depends: [ 13 + "ocaml" {>= "5.1.0"} 14 + "dune" {>= "3.17.0"} 15 + ] 16 + available: arch != "arm32" & arch != "x86_32" 17 + synopsis: "Intrinsics" 18 + description: " 19 + Provides functions to invoke amd64 instructions (such as cmov, min/maxsd, popcnt) 20 + when available, or compatible software implementation on other targets. 21 + See also ocaml_intrinsics library. 22 + "
+12
vendor/opam/ocaml_intrinsics_kernel/src/common.ml
··· 1 + let available = 2 + match Sys.backend_type with 3 + | Native -> 4 + (* (match Sys.unix with 5 + * | false -> false 6 + * | true -> 7 + * (match Sys.architecture with 8 + * | "amd64" | "arm64" -> true 9 + * | _ -> false)) *) 10 + Sys.unix 11 + | Bytecode | Other _ -> false 12 + ;;
+4
vendor/opam/ocaml_intrinsics_kernel/src/common.mli
··· 1 + (** Are optimized C stubs available? If not, naive implementation will be used. The value 2 + is statically known and depends on the current compiler's configuration (system, 3 + target, architecture). *) 4 + val available : bool
+66
vendor/opam/ocaml_intrinsics_kernel/src/conditional.ml
··· 1 + (** [select_value c a b] is equivalent to [if c then a else b)] where [a] and [b] are 2 + eagerly evaluated, regardless of the value of [c]. Compiles to CMOV instruction on 3 + amd64 targets. Can be used to avoid branch misprediction when [c] is data dependent. *) 4 + external select_value 5 + : 'a. 6 + bool -> ('a[@local_opt]) -> ('a[@local_opt]) -> ('a[@local_opt]) 7 + = "caml_csel_value" 8 + [@@noalloc] [@@no_effects] [@@no_coeffects] [@@builtin] 9 + 10 + external select_int 11 + : bool 12 + -> (int[@untagged]) 13 + -> (int[@untagged]) 14 + -> (int[@untagged]) 15 + = "caml_csel_value" "caml_csel_int_untagged" 16 + [@@noalloc] [@@no_effects] [@@no_coeffects] [@@builtin] 17 + 18 + external select_int64 19 + : bool 20 + -> (int64[@unboxed]) 21 + -> (int64[@unboxed]) 22 + -> (int64[@unboxed]) 23 + = "caml_csel_value" "caml_csel_int64_unboxed" 24 + [@@noalloc] [@@no_effects] [@@no_coeffects] [@@builtin] 25 + 26 + external select_int32 27 + : bool 28 + -> (int32[@unboxed]) 29 + -> (int32[@unboxed]) 30 + -> (int32[@unboxed]) 31 + = "caml_csel_value" "caml_csel_int32_unboxed" 32 + [@@noalloc] [@@no_effects] [@@no_coeffects] [@@builtin] 33 + 34 + external select_nativeint 35 + : bool 36 + -> (nativeint[@unboxed]) 37 + -> (nativeint[@unboxed]) 38 + -> (nativeint[@unboxed]) 39 + = "caml_csel_value" "caml_csel_nativeint_unboxed" 40 + [@@noalloc] [@@no_effects] [@@no_coeffects] [@@builtin] 41 + 42 + module Unboxed = struct 43 + external select_int64 44 + : bool 45 + -> (int64[@unboxed]) 46 + -> (int64[@unboxed]) 47 + -> (int64[@unboxed]) 48 + = "caml_csel_value" "caml_csel_int64_unboxed" 49 + [@@noalloc] [@@no_effects] [@@no_coeffects] [@@builtin] 50 + 51 + external select_int32 52 + : bool 53 + -> (int32[@unboxed]) 54 + -> (int32[@unboxed]) 55 + -> (int32[@unboxed]) 56 + = "caml_csel_value" "caml_csel_int32_unboxed" 57 + [@@noalloc] [@@no_effects] [@@no_coeffects] [@@builtin] 58 + 59 + external select_nativeint 60 + : bool 61 + -> (nativeint[@unboxed]) 62 + -> (nativeint[@unboxed]) 63 + -> (nativeint[@unboxed]) 64 + = "caml_csel_value" "caml_csel_nativeint_unboxed" 65 + [@@noalloc] [@@no_effects] [@@no_coeffects] [@@builtin] 66 + end
+26
vendor/opam/ocaml_intrinsics_kernel/src/conditional_stubs.c
··· 1 + #include "caml/mlvalues.h" 2 + 3 + intnat caml_csel_int_untagged(value v_cond, intnat ifso, intnat ifnot) 4 + { 5 + return (Bool_val(v_cond) ? ifso : ifnot); 6 + } 7 + 8 + uint64_t caml_csel_int64_unboxed(value v_cond, uint64_t ifso, uint64_t ifnot) 9 + { 10 + return (Bool_val(v_cond) ? ifso : ifnot); 11 + } 12 + 13 + uint32_t caml_csel_int32_unboxed(value v_cond, uint32_t ifso, uint32_t ifnot) 14 + { 15 + return (Bool_val(v_cond) ? ifso : ifnot); 16 + } 17 + 18 + intnat caml_csel_nativeint_unboxed(value v_cond, intnat ifso, intnat ifnot) 19 + { 20 + return (Bool_val(v_cond) ? ifso : ifnot); 21 + } 22 + 23 + CAMLprim value caml_csel_value(value v_cond, value v_true, value v_false) 24 + { 25 + return (Bool_val(v_cond) ? v_true : v_false); 26 + }
+14
vendor/opam/ocaml_intrinsics_kernel/src/dune
··· 1 + (library 2 + (foreign_stubs 3 + (language c) 4 + (names conditional_stubs float_stubs int_stubs)) 5 + (name ocaml_intrinsics_kernel) 6 + (public_name ocaml_intrinsics_kernel) 7 + (libraries) 8 + (ocamlopt_flags :standard -O3) 9 + (js_of_ocaml 10 + (javascript_files runtime.js)) 11 + (preprocess no_preprocessing) 12 + (wasm_of_ocaml 13 + (javascript_files runtime.js) 14 + (wasm_files runtime.wat)))
+41
vendor/opam/ocaml_intrinsics_kernel/src/float.ml
··· 1 + external min 2 + : (float[@unboxed]) 3 + -> (float[@unboxed]) 4 + -> (float[@unboxed]) 5 + = "caml_sse2_float64_min_bytecode" "caml_sse2_float64_min" 6 + [@@noalloc] 7 + 8 + external max 9 + : (float[@unboxed]) 10 + -> (float[@unboxed]) 11 + -> (float[@unboxed]) 12 + = "caml_sse2_float64_max_bytecode" "caml_sse2_float64_max" 13 + [@@noalloc] 14 + 15 + external iround_current 16 + : (float[@unboxed]) 17 + -> (int64[@unboxed]) 18 + = "caml_sse2_cast_float64_int64_bytecode" "caml_sse2_cast_float64_int64" 19 + [@@noalloc] 20 + 21 + module Unboxed = struct 22 + external min 23 + : (float[@unboxed]) 24 + -> (float[@unboxed]) 25 + -> (float[@unboxed]) 26 + = "caml_sse2_float64_min_bytecode" "caml_sse2_float64_min" 27 + [@@noalloc] 28 + 29 + external max 30 + : (float[@unboxed]) 31 + -> (float[@unboxed]) 32 + -> (float[@unboxed]) 33 + = "caml_sse2_float64_max_bytecode" "caml_sse2_float64_max" 34 + [@@noalloc] 35 + 36 + external iround_current 37 + : (float[@unboxed]) 38 + -> (int64[@unboxed]) 39 + = "caml_sse2_cast_float64_int64_bytecode" "caml_sse2_cast_float64_int64" 40 + [@@noalloc] 41 + end
+65
vendor/opam/ocaml_intrinsics_kernel/src/float.mli
··· 1 + (** X86 docs say: 2 + 3 + If only one value is a NaN (SNaN or QNaN) for this instruction, the second source 4 + operand, either a NaN or a valid floating-point value is written to the result. 5 + 6 + So we have to be VERY careful how we use these! *) 7 + 8 + (** Equivalent to [if x < y then x else y]. 9 + 10 + On an x86-64 machine, this compiles to [minsd xmm0, xmm1]. On ARM, this calls a C 11 + implementation. *) 12 + external min 13 + : (float[@unboxed]) 14 + -> (float[@unboxed]) 15 + -> (float[@unboxed]) 16 + = "caml_sse2_float64_min_bytecode" "caml_sse2_float64_min" 17 + [@@noalloc] 18 + 19 + (** Equivalent to [if x > y then x else y]. 20 + 21 + On an x86-64 machine, this compiles to [maxsd xmm0, xmm1]. On ARM, this calls a C 22 + implementation. *) 23 + external max 24 + : (float[@unboxed]) 25 + -> (float[@unboxed]) 26 + -> (float[@unboxed]) 27 + = "caml_sse2_float64_max_bytecode" "caml_sse2_float64_max" 28 + [@@noalloc] 29 + 30 + (** Rounds a [float] to an [int64] using the current rounding mode. In native code, the 31 + default rounding mode is "round half to even," and we expect that no program will 32 + change the rounding mode. 33 + 34 + If the argument is NaN or infinite or if the rounded value cannot be represented, the 35 + result is unspecified. 36 + 37 + On an x86-64 machine, this compiles to [cvtsd2si rax, xmm0]. On ARM, this calls a C 38 + implementation. *) 39 + external iround_current 40 + : (float[@unboxed]) 41 + -> (int64[@unboxed]) 42 + = "caml_sse2_cast_float64_int64_bytecode" "caml_sse2_cast_float64_int64" 43 + [@@noalloc] 44 + 45 + module Unboxed : sig 46 + external min 47 + : (float[@unboxed]) 48 + -> (float[@unboxed]) 49 + -> (float[@unboxed]) 50 + = "caml_sse2_float64_min_bytecode" "caml_sse2_float64_min" 51 + [@@noalloc] 52 + 53 + external max 54 + : (float[@unboxed]) 55 + -> (float[@unboxed]) 56 + -> (float[@unboxed]) 57 + = "caml_sse2_float64_max_bytecode" "caml_sse2_float64_max" 58 + [@@noalloc] 59 + 60 + external iround_current 61 + : (float[@unboxed]) 62 + -> (int64[@unboxed]) 63 + = "caml_sse2_cast_float64_int64_bytecode" "caml_sse2_cast_float64_int64" 64 + [@@noalloc] 65 + end
+65
vendor/opam/ocaml_intrinsics_kernel/src/float_stubs.c
··· 1 + #include <stdint.h> 2 + #include <assert.h> 3 + 4 + #include <caml/alloc.h> 5 + #include <caml/mlvalues.h> 6 + 7 + #if defined(__SSE2__) || defined(_MSC_VER) 8 + 9 + #ifdef _MSC_VER 10 + #include <intrin.h> 11 + #else // _MSC_VER 12 + #include <emmintrin.h> 13 + #endif // _MSC_VER 14 + 15 + double caml_sse2_float64_min(double x, double y) 16 + { 17 + return _mm_cvtsd_f64(_mm_min_sd(_mm_set_sd(x), _mm_set_sd(y))); 18 + } 19 + 20 + double caml_sse2_float64_max(double x, double y) 21 + { 22 + return _mm_cvtsd_f64(_mm_max_sd(_mm_set_sd(x), _mm_set_sd(y))); 23 + } 24 + 25 + int64_t caml_sse2_cast_float64_int64(double x) 26 + { 27 + return _mm_cvtsd_si64(_mm_set_sd(x)); 28 + } 29 + 30 + #else // __SSE2__ || _MSC_VER 31 + 32 + #include <math.h> 33 + 34 + double caml_sse2_float64_min(double x, double y) { 35 + return x < y ? x : y; 36 + } 37 + 38 + double caml_sse2_float64_max(double x, double y) { 39 + return x > y ? x : y; 40 + } 41 + 42 + #if defined(__GNUC__) && !defined(__llvm__) 43 + __attribute__((optimize("no-math-errno"))) 44 + #endif 45 + int64_t caml_sse2_cast_float64_int64(double x) 46 + { 47 + return llrint(x); 48 + } 49 + 50 + #endif // __SSE2__ 51 + 52 + CAMLprim value caml_sse2_float64_min_bytecode(value x, value y) 53 + { 54 + return caml_copy_double(caml_sse2_float64_min(Double_val(x), Double_val(y))); 55 + } 56 + 57 + CAMLprim value caml_sse2_float64_max_bytecode(value x, value y) 58 + { 59 + return caml_copy_double(caml_sse2_float64_max(Double_val(x), Double_val(y))); 60 + } 61 + 62 + CAMLprim value caml_sse2_cast_float64_int64_bytecode(value x) 63 + { 64 + return caml_copy_int64(caml_sse2_cast_float64_int64(Double_val(x))); 65 + }
+87
vendor/opam/ocaml_intrinsics_kernel/src/int.ml
··· 1 + (** The are two version of [count_leading_zeros], [count_set_bits] each, which differ in 2 + their native code implementation. The first version takes as input a tagged integer 3 + and the second version takes as input an untagged integer. Generally, the first 4 + version (that operates on a tagged integer) is faster, but if the integer is already 5 + untagged, it may be faster to use the second version. *) 6 + 7 + module Stubs = struct 8 + let available = Common.available 9 + 10 + (** [count_leading_zeros n] returns the number of most-significant zero bits before the 11 + most significant set bit in [n]. If [n] is 0, the result is the number of bits in 12 + [n], that is 31 or 63, depending on the target. *) 13 + external count_leading_zeros 14 + : int 15 + -> (int[@untagged]) 16 + = "caml_int_clz" "caml_int_clz_tagged_to_untagged" 17 + [@@noalloc] [@@builtin] [@@no_effects] [@@no_coeffects] 18 + 19 + external count_leading_zeros2 20 + : int 21 + -> int 22 + = "caml_int_clz" "caml_int_clz_untagged_to_untagged" 23 + [@@untagged] [@@noalloc] [@@builtin] [@@no_effects] [@@no_coeffects] 24 + 25 + (** [count_set_bits n] returns the number of bits that are 1 in [n]. *) 26 + external count_set_bits 27 + : int 28 + -> (int[@untagged]) 29 + = "caml_int_popcnt" "caml_int_popcnt_tagged_to_untagged" 30 + [@@noalloc] [@@builtin] [@@no_effects] [@@no_coeffects] 31 + 32 + external count_set_bits2 33 + : int 34 + -> int 35 + = "caml_int_popcnt" "caml_int_popcnt_untagged_to_untagged" 36 + [@@untagged] [@@noalloc] [@@builtin] [@@no_effects] [@@no_coeffects] 37 + 38 + (** [count_trailing_zeros n] returns the number of least-significant zero bits before 39 + the least significant set bit in [n]. If [n] is 0, the result is the number of bits 40 + in [n], that is 31 or 63, depending on the target. *) 41 + external count_trailing_zeros 42 + : int 43 + -> int 44 + = "caml_int_ctz" "caml_int_ctz_untagged_to_untagged" 45 + [@@untagged] [@@noalloc] [@@builtin] [@@no_effects] [@@no_coeffects] 46 + end 47 + 48 + module Naive = Naive_ints.Make (struct 49 + include Stdlib.Int 50 + 51 + external compare : t -> t -> int = "%compare" 52 + external equal : t -> t -> bool = "%equal" 53 + 54 + let bitwidth = Sys.int_size 55 + let to_int = Fun.id 56 + let of_int t = t 57 + end) 58 + 59 + let[@inline always] count_leading_zeros n = 60 + match Stubs.available with 61 + | true -> Stubs.count_leading_zeros n 62 + | false -> Naive.count_leading_zeros n 63 + ;; 64 + 65 + let[@inline always] count_leading_zeros2 n = 66 + match Stubs.available with 67 + | true -> Stubs.count_leading_zeros2 n 68 + | false -> Naive.count_leading_zeros n 69 + ;; 70 + 71 + let[@inline always] count_set_bits2 n = 72 + match Stubs.available with 73 + | true -> Stubs.count_set_bits2 n 74 + | false -> Naive.count_set_bits n 75 + ;; 76 + 77 + let[@inline always] count_trailing_zeros n = 78 + match Stubs.available with 79 + | true -> Stubs.count_trailing_zeros n 80 + | false -> Naive.count_trailing_zeros n 81 + ;; 82 + 83 + let[@inline always] count_set_bits n = 84 + match Stubs.available with 85 + | true -> Stubs.count_set_bits n 86 + | false -> Naive.count_set_bits n 87 + ;;
+34
vendor/opam/ocaml_intrinsics_kernel/src/int.mli
··· 1 + (** The are two versions of [count_leading_zeros] and [count_set_bits]. They have the same 2 + types, but their native code implementations differ. 3 + 4 + The first version inputs a tagged integer and the second version inputs an untagged 5 + integer. Generally, the first version (operating on a tagged integer) is faster, but 6 + if the untagged integer is already available in the surrounding context, the second 7 + version may be faster. *) 8 + 9 + (** [count_leading_zeros n] returns the number of most-significant zero bits before the 10 + most significant set bit in [n]. If [n] is 0, the result is the number of bits in [n], 11 + that is 31 or 63, depending on the target. *) 12 + val count_leading_zeros : int -> int 13 + 14 + (** [count_leading_zeros2 n] computes the same result as [count_leading_zeros n]. 15 + 16 + The functions only differ in optimizations that the compiler may be able to perform 17 + around the call. In particular, the implementation of [count_leading_zeros n] may 18 + operate directly on tagged n. *) 19 + val count_leading_zeros2 : int -> int 20 + 21 + (** [count_set_bits n] returns the number of bits that are 1 in [n]. *) 22 + val count_set_bits : int -> int 23 + 24 + (** [count_set_bits2 n] computes the same result as [count_set_bits n]. 25 + 26 + The functions only differs in optimizations that the compiler may be able to perform 27 + around the call. In particular, the implementation of [count_set_bits n] may operate 28 + directly on tagged n. *) 29 + val count_set_bits2 : int -> int 30 + 31 + (** [count_trailing_zeros n] returns the number of least-significant zero bits before the 32 + least significant set bit in [n]. If [n] is 0, the result is the number of bits in 33 + [n], that is 31 or 63, depending on the target. *) 34 + val count_trailing_zeros : int -> int
+123
vendor/opam/ocaml_intrinsics_kernel/src/int32.ml
··· 1 + module Stubs = struct 2 + let available = Common.available 3 + 4 + (** [count_leading_zeros n] returns the number of most-significant zero bits before the 5 + most significant set bit in [n]. If [n] is 0, the result is the number of bits in 6 + [n], that is 32. *) 7 + external count_leading_zeros 8 + : (int32[@unboxed] [@local_opt]) 9 + -> (int32[@unboxed]) 10 + = "caml_int32_clz" "caml_int32_clz_unboxed_to_untagged" 11 + [@@noalloc] [@@builtin] [@@no_effects] [@@no_coeffects] 12 + 13 + (** Same as [count_leading_zeros] except if the argument is zero, then the result is 14 + undefined. Emits more efficient code. *) 15 + external count_leading_zeros_nonzero_arg 16 + : (int32[@unboxed] [@local_opt]) 17 + -> (int32[@unboxed]) 18 + = "caml_int32_clz" "caml_int32_clz_nonzero_unboxed_to_untagged" 19 + [@@noalloc] [@@builtin] [@@no_effects] [@@no_coeffects] 20 + 21 + (** [count_trailing_zeros n] returns the number of least-significant zero bits before 22 + the least significant set bit in [n]. If [n] is 0, the result is the number of bits 23 + in [n], that is 32. *) 24 + external count_trailing_zeros 25 + : (int32[@unboxed] [@local_opt]) 26 + -> (int32[@unboxed]) 27 + = "caml_int32_ctz" "caml_int32_ctz_unboxed_to_untagged" 28 + [@@noalloc] [@@builtin] [@@no_effects] [@@no_coeffects] 29 + 30 + (** Same as [count_trailing_zeros] except if the argument is zero, then the result is 31 + undefined. Emits more efficient code. *) 32 + external count_trailing_zeros_nonzero_arg 33 + : (int32[@unboxed] [@local_opt]) 34 + -> (int32[@unboxed]) 35 + = "caml_int32_ctz" "caml_int32_ctz_nonzero_unboxed_to_untagged" 36 + [@@noalloc] [@@builtin] [@@no_effects] [@@no_coeffects] 37 + 38 + (** [count_set_bits n] returns the number of bits that are 1 in [n]. *) 39 + external count_set_bits 40 + : (int32[@unboxed] [@local_opt]) 41 + -> (int32[@unboxed]) 42 + = "caml_int32_popcnt" "caml_int32_popcnt_unboxed_to_untagged" 43 + [@@noalloc] [@@builtin] [@@no_effects] [@@no_coeffects] 44 + 45 + external shift_left 46 + : (int32[@local_opt]) 47 + -> (int32[@local_opt]) 48 + -> (int32[@local_opt]) 49 + = "caml_int32_shift_left_by_int32" "caml_int32_shift_left_by_int32_unboxed" 50 + [@@noalloc] (* [@@builtin] *) [@@no_effects] [@@no_coeffects] [@@unboxed] 51 + 52 + external shift_right 53 + : (int32[@local_opt]) 54 + -> (int32[@local_opt]) 55 + -> (int32[@local_opt]) 56 + = "caml_int32_shift_right_by_int32" "caml_int32_shift_right_by_int32_unboxed" 57 + [@@noalloc] (* [@@builtin] *) [@@no_effects] [@@no_coeffects] [@@unboxed] 58 + 59 + external shift_right_logical 60 + : (int32[@local_opt]) 61 + -> (int32[@local_opt]) 62 + -> (int32[@local_opt]) 63 + = "caml_int32_shift_right_logical_by_int32" 64 + "caml_int32_shift_right_logical_by_int32_unboxed" 65 + [@@noalloc] (* [@@builtin] *) [@@no_effects] [@@no_coeffects] [@@unboxed] 66 + end 67 + 68 + module Naive = Naive_ints.Make (struct 69 + include Stdlib.Int32 70 + 71 + external compare : t -> t -> int = "%compare" 72 + external equal : t -> t -> bool = "%equal" 73 + 74 + let bitwidth = 32l 75 + end) 76 + 77 + let[@inline always] count_leading_zeros n = 78 + match Stubs.available with 79 + | true -> Stubs.count_leading_zeros n 80 + | false -> Naive.count_leading_zeros n 81 + ;; 82 + 83 + let[@inline always] count_leading_zeros_nonzero_arg n = 84 + match Stubs.available with 85 + | true -> Stubs.count_leading_zeros_nonzero_arg n 86 + | false -> Naive.count_leading_zeros n 87 + ;; 88 + 89 + let[@inline always] count_trailing_zeros n = 90 + match Stubs.available with 91 + | true -> Stubs.count_trailing_zeros n 92 + | false -> Naive.count_trailing_zeros n 93 + ;; 94 + 95 + let[@inline always] count_trailing_zeros_nonzero_arg n = 96 + match Stubs.available with 97 + | true -> Stubs.count_trailing_zeros_nonzero_arg n 98 + | false -> Naive.count_trailing_zeros n 99 + ;; 100 + 101 + let[@inline always] count_set_bits n = 102 + match Stubs.available with 103 + | true -> Stubs.count_set_bits n 104 + | false -> Naive.count_set_bits n 105 + ;; 106 + 107 + let[@inline always] shift_left x y = 108 + match Stubs.available with 109 + | true -> Stubs.shift_left x y 110 + | false -> Naive.shift_left x y 111 + ;; 112 + 113 + let[@inline always] shift_right x y = 114 + match Stubs.available with 115 + | true -> Stubs.shift_right x y 116 + | false -> Naive.shift_right x y 117 + ;; 118 + 119 + let[@inline always] shift_right_logical x y = 120 + match Stubs.available with 121 + | true -> Stubs.shift_right_logical x y 122 + | false -> Naive.shift_right_logical x y 123 + ;;
+47
vendor/opam/ocaml_intrinsics_kernel/src/int32.mli
··· 1 + (** [count_leading_zeros n] returns the number of most-significant zero bits before the 2 + most significant set bit in [n]. If [n] is 0, the result is the number of bits in [n], 3 + that is 32. *) 4 + val count_leading_zeros : int32 -> int32 5 + 6 + (** Same as [count_leading_zeros] except if the argument is zero, then the result is 7 + undefined. Emits more efficient code. 8 + 9 + This is no longer needed when using an flambda-backend compiler, which translates 10 + [count_leading_zeros] to LZCNT by default (amd64). *) 11 + val count_leading_zeros_nonzero_arg : int32 -> int32 12 + 13 + (** [count_trailing_zeros n] returns the number of least-significant zero bits before the 14 + least significant set bit in [n]. If [n] is 0, the result is the number of bits in 15 + [n], that is 32. *) 16 + val count_trailing_zeros : int32 -> int32 17 + 18 + (** Same as [count_trailing_zeros] except if the argument is zero, then the result is 19 + undefined. Emits more efficient code. 20 + 21 + This is no longer needed when using an flambda-backend compiler, which translates 22 + [count_trailing_zeros] to TZCNT by default (amd64). *) 23 + val count_trailing_zeros_nonzero_arg : int32 -> int32 24 + 25 + (** [count_set_bits n] returns the number of bits that are 1 in [n]. *) 26 + val count_set_bits : int32 -> int32 27 + 28 + (** Shift operations below differ from the corresponding [Stdlib.Int32.shift_*] operations 29 + in two ways: 30 + (a) shift count (second argument) is the same type as the first argument, allowing 31 + unboxed types to be used as counts. 32 + (b) the operations are defined for arbitrary shift counts and rely on the hardware to 33 + mask the shift to [bitwidth-1] bits, where [bitwidth] is determined by the type of 34 + the first argument. *) 35 + 36 + (** [shift_left x y] shifts [x] to the left by [y & (bitwidth-1)] bits. *) 37 + val shift_left : int32 -> int32 -> int32 38 + 39 + (** [Int32.shift_right x y] shifts [x] to the right by [y] bits. This is an arithmetic 40 + shift: the sign bit of [x] is replicated and inserted in the vacated bits. *) 41 + val shift_right : int32 -> int32 -> int32 42 + 43 + (** [Int32.shift_right_logical x y] shifts [x] to the right by [y] bits. This is a logical 44 + shift: zeroes are inserted in the vacated bits regardless of the sign of [x]. *) 45 + val shift_right_logical : int32 -> int32 -> int32 46 + 47 + module Naive : Naive_ints.S with type t = int32
+123
vendor/opam/ocaml_intrinsics_kernel/src/int64.ml
··· 1 + module Stubs = struct 2 + let available = Common.available 3 + 4 + (** [count_leading_zeros n] returns the number of most-significant zero bits before the 5 + most significant set bit in [n]. If [n] is 0, the result is the number of bits in 6 + [n], that is 64. *) 7 + external count_leading_zeros 8 + : (int64[@unboxed] [@local_opt]) 9 + -> (int64[@unboxed]) 10 + = "caml_int64_clz" "caml_int64_clz_unboxed_to_untagged" 11 + [@@noalloc] [@@builtin] [@@no_effects] [@@no_coeffects] 12 + 13 + (** Same as [count_leading_zeros] except if the argument is zero, then the result is 14 + undefined. Emits more efficient code. *) 15 + external count_leading_zeros_nonzero_arg 16 + : (int64[@unboxed] [@local_opt]) 17 + -> (int64[@unboxed]) 18 + = "caml_int64_clz" "caml_int64_clz_nonzero_unboxed_to_untagged" 19 + [@@noalloc] [@@builtin] [@@no_effects] [@@no_coeffects] 20 + 21 + (** [count_trailing_zeros n] returns the number of least-significant zero bits before 22 + the least significant set bit in [n]. If [n] is 0, the result is the number of bits 23 + in [n], that is 64. *) 24 + external count_trailing_zeros 25 + : (int64[@unboxed] [@local_opt]) 26 + -> (int64[@unboxed]) 27 + = "caml_int64_ctz" "caml_int64_ctz_unboxed_to_untagged" 28 + [@@noalloc] [@@builtin] [@@no_effects] [@@no_coeffects] 29 + 30 + (** Same as [count_trailing_zeros] except if the argument is zero, then the result is 31 + undefined. Emits more efficient code. *) 32 + external count_trailing_zeros_nonzero_arg 33 + : (int64[@unboxed] [@local_opt]) 34 + -> (int64[@unboxed]) 35 + = "caml_int64_ctz" "caml_int64_ctz_nonzero_unboxed_to_untagged" 36 + [@@noalloc] [@@builtin] [@@no_effects] [@@no_coeffects] 37 + 38 + (** [count_set_bits n] returns the number of bits that are 1 in [n]. *) 39 + external count_set_bits 40 + : (int64[@unboxed] [@local_opt]) 41 + -> (int64[@unboxed]) 42 + = "caml_int64_popcnt" "caml_int64_popcnt_unboxed_to_untagged" 43 + [@@noalloc] [@@builtin] [@@no_effects] [@@no_coeffects] 44 + 45 + external shift_left 46 + : (int64[@local_opt]) 47 + -> (int64[@local_opt]) 48 + -> (int64[@local_opt]) 49 + = "caml_int64_shift_left_by_int64" "caml_int64_shift_left_by_int64_unboxed" 50 + [@@noalloc] (* [@@builtin] *) [@@no_effects] [@@no_coeffects] [@@unboxed] 51 + 52 + external shift_right 53 + : (int64[@local_opt]) 54 + -> (int64[@local_opt]) 55 + -> (int64[@local_opt]) 56 + = "caml_int64_shift_right_by_int64" "caml_int64_shift_right_by_int64_unboxed" 57 + [@@noalloc] (* [@@builtin] *) [@@no_effects] [@@no_coeffects] [@@unboxed] 58 + 59 + external shift_right_logical 60 + : (int64[@local_opt]) 61 + -> (int64[@local_opt]) 62 + -> (int64[@local_opt]) 63 + = "caml_int64_shift_right_logical_by_int64" 64 + "caml_int64_shift_right_logical_by_int64_unboxed" 65 + [@@noalloc] (* [@@builtin] *) [@@no_effects] [@@no_coeffects] [@@unboxed] 66 + end 67 + 68 + module Naive = Naive_ints.Make (struct 69 + include Stdlib.Int64 70 + 71 + external compare : t -> t -> int = "%compare" 72 + external equal : t -> t -> bool = "%equal" 73 + 74 + let bitwidth = 64L 75 + end) 76 + 77 + let[@inline always] count_leading_zeros n = 78 + match Stubs.available with 79 + | true -> Stubs.count_leading_zeros n 80 + | false -> Naive.count_leading_zeros n 81 + ;; 82 + 83 + let[@inline always] count_leading_zeros_nonzero_arg n = 84 + match Stubs.available with 85 + | true -> Stubs.count_leading_zeros_nonzero_arg n 86 + | false -> Naive.count_leading_zeros n 87 + ;; 88 + 89 + let[@inline always] count_trailing_zeros n = 90 + match Stubs.available with 91 + | true -> Stubs.count_trailing_zeros n 92 + | false -> Naive.count_trailing_zeros n 93 + ;; 94 + 95 + let[@inline always] count_trailing_zeros_nonzero_arg n = 96 + match Stubs.available with 97 + | true -> Stubs.count_trailing_zeros_nonzero_arg n 98 + | false -> Naive.count_trailing_zeros n 99 + ;; 100 + 101 + let[@inline always] count_set_bits n = 102 + match Stubs.available with 103 + | true -> Stubs.count_set_bits n 104 + | false -> Naive.count_set_bits n 105 + ;; 106 + 107 + let[@inline always] shift_left x y = 108 + match Stubs.available with 109 + | true -> Stubs.shift_left x y 110 + | false -> Naive.shift_left x y 111 + ;; 112 + 113 + let[@inline always] shift_right x y = 114 + match Stubs.available with 115 + | true -> Stubs.shift_right x y 116 + | false -> Naive.shift_right x y 117 + ;; 118 + 119 + let[@inline always] shift_right_logical x y = 120 + match Stubs.available with 121 + | true -> Stubs.shift_right_logical x y 122 + | false -> Naive.shift_right_logical x y 123 + ;;
+48
vendor/opam/ocaml_intrinsics_kernel/src/int64.mli
··· 1 + (** [count_leading_zeros n] returns the number of most-significant zero bits before the 2 + most significant set bit in [n]. If [n] is 0, the result is the number of bits in [n], 3 + that is 64. *) 4 + val count_leading_zeros : int64 -> int64 5 + 6 + (** Same as [count_leading_zeros] except if the argument is zero, then the result is 7 + undefined. Emits more efficient code. 8 + 9 + This is no longer needed when using an flambda-backend compiler, which translates 10 + [count_leading_zeros] to LZCNT by default (amd64). *) 11 + val count_leading_zeros_nonzero_arg : int64 -> int64 12 + 13 + (** [count_trailing_zeros n] returns the number of least-significant zero bits before the 14 + least significant set bit in [n]. If [n] is 0, the result is the number of bits in 15 + [n], that is 64. *) 16 + val count_trailing_zeros : int64 -> int64 17 + 18 + (** Same as [count_trailing_zeros] except if the argument is zero, then the result is 19 + undefined. Emits more efficient code. 20 + 21 + This is no longer needed when using an flambda-backend compiler, which translates 22 + [count_trailing_zeros] to TZCNT by default (amd64). *) 23 + val count_trailing_zeros_nonzero_arg : int64 -> int64 24 + 25 + (** [count_set_bits n] returns the number of bits that are 1 in [n]. *) 26 + 27 + val count_set_bits : int64 -> int64 28 + 29 + (** Shift operations below differ from the corresponding [Stdlib.Int64.shift_*] operations 30 + in two ways: 31 + (a) shift count (second argument) is the same type as the first argument, allowing 32 + unboxed types to be used as counts. 33 + (b) the operations are defined for arbitrary shift counts and rely on the hardware to 34 + mask the count to [bitwidth-1] bits, where [bitwidth] is determined by the type of 35 + the first argument. *) 36 + 37 + (** [shift_left x y] shifts [x] to the left by [y & (bitwidth-1)] bits. *) 38 + val shift_left : int64 -> int64 -> int64 39 + 40 + (** [Int64.shift_right x y] shifts [x] to the right by [y] bits. This is an arithmetic 41 + shift: the sign bit of [x] is replicated and inserted in the vacated bits. *) 42 + val shift_right : int64 -> int64 -> int64 43 + 44 + (** [Int64.shift_right_logical x y] shifts [x] to the right by [y] bits. This is a logical 45 + shift: zeroes are inserted in the vacated bits regardless of the sign of [x]. *) 46 + val shift_right_logical : int64 -> int64 -> int64 47 + 48 + module Naive : Naive_ints.S with type t = int64
+505
vendor/opam/ocaml_intrinsics_kernel/src/int_stubs.c
··· 1 + #include "caml/config.h" 2 + #include "caml/alloc.h" 3 + #include "caml/misc.h" 4 + #include "caml/mlvalues.h" 5 + 6 + 7 + #if defined(__GNUC__) 8 + #if ARCH_INT32_TYPE == long 9 + #define int32_clz __builtin_clzl 10 + #define int32_ctz __builtin_ctzl 11 + #define int32_popcnt __builtin_popcountl 12 + #else /* ARCH_INT32_TYPE == long */ 13 + #define int32_clz __builtin_clz 14 + #define int32_ctz __builtin_ctz 15 + #define int32_popcnt __builtin_popcount 16 + #endif /* ARCH_INT32_TYPE == long */ 17 + #define int64_clz __builtin_clzll 18 + #define int64_ctz __builtin_ctzll 19 + #define int64_popcnt __builtin_popcountll 20 + #else /* defined(__GNUC__) */ 21 + #ifdef _MSC_VER 22 + #pragma message("Functionality on Windows has not been tested") 23 + #include <intrin.h> 24 + #pragma intrinsic(_BitScanReverse) 25 + 26 + intnat naive_int64_clz(uint64_t v) 27 + { 28 + unsigned long n; 29 + #ifdef ARCH_SIXTYFOUR 30 + if (_BitScanReverse64(&n, v)) return 63-n; 31 + else return 64; 32 + #else 33 + /* _BitScanReverse64 is not supported */ 34 + if ((v >> 32) == 0) 35 + { 36 + if (_BitScanReverse(&n,v)) return 63-n; 37 + else return 64; 38 + } 39 + else 40 + { 41 + _BitScanReverse(&n,(v>>32)); 42 + return 31-n; 43 + } 44 + #endif 45 + } 46 + 47 + intnat naive_int32_clz(uint32_t v) 48 + { 49 + unsigned long n; 50 + if (_BitScanReverse(&n, v)) 51 + #ifdef ARCH_SIXTYFOUR 52 + return 63 - n; 53 + #else 54 + return 31 - n; 55 + #endif 56 + else return 32; 57 + } 58 + 59 + #pragma intrinsic(_BitScanForward) 60 + 61 + intnat naive_int64_ctz(uint64_t v) 62 + { 63 + unsigned long n; 64 + #ifdef ARCH_SIXTYFOUR 65 + if (_BitScanForward64(&n, v)) return n; 66 + else return 64; 67 + #else 68 + /* _BitScanForward64 is not supported */ 69 + if ((v << 32) == 0) 70 + { 71 + if (_BitScanForward(&n,(v>>32))) return n+32; 72 + else return 64; 73 + } 74 + else 75 + { 76 + _BitScanForward(&n,v); 77 + return n; 78 + } 79 + #endif 80 + } 81 + 82 + intnat naive_int32_ctz(uint32_t v) 83 + { 84 + unsigned long n; 85 + if (_BitScanForward(&n, v)) return n; 86 + else return 32; 87 + } 88 + 89 + /* _MSVC_ intrinsic for popcnt is not supported on all targets. 90 + Use naive version of clz and popcnt from Hacker's Delight. */ 91 + 92 + intnat naive_int64_popcnt (uint64_t x) 93 + { 94 + int n = 0; 95 + while (x != 0) { 96 + n = n + 1; 97 + x = x & (x - 1); 98 + } 99 + return n; 100 + } 101 + 102 + intnat naive_int32_popcnt (uint32_t x) 103 + { 104 + int n = 0; 105 + while (x != 0) { 106 + n = n + 1; 107 + x = x & (x - 1); 108 + } 109 + return n; 110 + } 111 + 112 + #define int32_clz naive_int32_clz 113 + #define int64_clz naive_int64_clz 114 + #define int32_ctz naive_int32_ctz 115 + #define int64_ctz naive_int64_ctz 116 + #define int32_popcnt naive_int32_popcnt 117 + #define int64_popcnt naive_int64_popcnt 118 + #elif /* _MSC_VER */ 119 + #error "Target not supported" 120 + #endif /* _MSC_VER */ 121 + #endif /* defined(__GNUC__) */ 122 + 123 + 124 + #ifdef ARCH_SIXTYFOUR 125 + static inline intnat int32_clz_for_64bit(uint32_t v) 126 + { 127 + return int32_clz(v) - 32; 128 + } 129 + #undef int32_clz 130 + #define int32_clz int32_clz_for_64bit 131 + #endif 132 + 133 + intnat int32_clz_check_for_zero_arg(uint32_t x) 134 + { 135 + /* builtin_clz on input 0 is undefined */ 136 + if (x == 0) return 32; 137 + return int32_clz(x); 138 + } 139 + 140 + intnat int64_clz_check_for_zero_arg(uint64_t x) 141 + { 142 + /* builtin_clz on input 0 is undefined */ 143 + if (x == 0) return 64; 144 + else return int64_clz(x); 145 + } 146 + 147 + intnat int32_ctz_check_for_zero_arg(uint32_t x) 148 + { 149 + /* builtin_ctz on input 0 is undefined */ 150 + if (x == 0) return 32; 151 + else return int32_ctz(x); 152 + } 153 + 154 + intnat int64_ctz_check_for_zero_arg(uint64_t x) 155 + { 156 + /* builtin_clz on input 0 is undefined */ 157 + if (x == 0) return 64; 158 + else return int64_ctz(x); 159 + } 160 + 161 + /* Untagging of a negative value shifts in an extra bit. 162 + The following code clears the shifted sign bit of the argument. 163 + This straightline code is faster than conditional code 164 + for checking whether the argument is negative. */ 165 + #ifdef ARCH_SIXTYFOUR 166 + static inline uint64_t clear_sign_bit(intnat v1) 167 + { 168 + return ((uint64_t) v1) & ~(1ull << 63); 169 + } 170 + #else 171 + static inline uint32_t clear_sign_bit(intnat v1) 172 + { 173 + return ((uint32_t) v1) & ~(1ul << 31); 174 + 175 + } 176 + #endif 177 + 178 + 179 + /* Takes an untagged input and returns untagged output. */ 180 + intnat caml_int_clz_untagged_to_untagged(intnat v1) 181 + { 182 + #ifdef ARCH_SIXTYFOUR 183 + /* -1 because size of int is 63 not 64 (31 not 32, resp.) */ 184 + return int64_clz_check_for_zero_arg(clear_sign_bit(v1))-1; 185 + #else 186 + return int32_clz_check_for_zero_arg(clear_sign_bit(v1))-1; 187 + #endif 188 + } 189 + 190 + /* Takes a tagged input and returns untagged output. */ 191 + intnat caml_int_clz_tagged_to_untagged(value v1) 192 + { 193 + /* Do not use Long_val(v1) conversion, instead preserving the tag. 194 + It guarantees that the input to builtin_clz is non-zero, to guard 195 + against versions of builtin_clz that are undefined for input 0. 196 + The tag does not change the number of leading zeros. 197 + */ 198 + #ifdef ARCH_SIXTYFOUR 199 + return int64_clz((uint64_t)v1); 200 + #else 201 + return int32_clz((uint32_t)v1); 202 + #endif 203 + } 204 + 205 + CAMLprim value caml_int_clz(value v1) 206 + { 207 + return Val_long(caml_int_clz_tagged_to_untagged(v1)); 208 + } 209 + 210 + /* Takes an untagged input and returns untagged output. */ 211 + intnat caml_int_ctz_untagged_to_untagged(intnat v1) 212 + { 213 + /* 1 at the most-significant bit: it does not change the result, 214 + because size of OCaml [int] is 63 not 64 (31 not 32, resp.), 215 + and guarantees that the input to ctz is not zero. */ 216 + #ifdef ARCH_SIXTYFOUR 217 + return int64_ctz( ((uint64_t)v1) | (1ull << 63)); 218 + #else 219 + return int32_ctz(((uint32_t)v1) | (1ul << 31)); 220 + #endif 221 + } 222 + 223 + CAMLprim value caml_int_ctz(value v1) 224 + { 225 + return Val_long(caml_int_ctz_untagged_to_untagged(Long_val(v1))); 226 + } 227 + 228 + /* Takes untagged int and returns untagged int. */ 229 + intnat caml_int_popcnt_untagged_to_untagged(intnat v1) 230 + { 231 + /* Untagging brought in one more '1' for negative numbers. 232 + Clear the shifted sign bit. 233 + This implementation is expected to be faster than [popcnt(x) - 1] 234 + where x is tag(v1). */ 235 + #ifdef ARCH_SIXTYFOUR 236 + return int64_popcnt(clear_sign_bit(v1)); 237 + #else 238 + return int32_popcnt(clear_sign_bit(v1)); 239 + #endif 240 + } 241 + 242 + /* Takes tagged int and returns untagged int. */ 243 + intnat caml_int_popcnt_tagged_to_untagged(value v1) 244 + { 245 + /* Need -1 to account for the tag. */ 246 + #ifdef ARCH_SIXTYFOUR 247 + return int64_popcnt((uint64_t)v1) - 1; 248 + #else 249 + return int32_popcnt((uint32_t)v1) - 1; 250 + #endif 251 + } 252 + 253 + CAMLprim value caml_int_popcnt(value v1) 254 + { 255 + return Val_long(caml_int_popcnt_tagged_to_untagged(v1)); 256 + } 257 + 258 + 259 + intnat caml_int32_clz_unboxed_to_untagged(int32_t v) 260 + { 261 + return int32_clz_check_for_zero_arg((uint32_t) v); 262 + } 263 + 264 + intnat caml_int32_ctz_unboxed_to_untagged(int32_t v) 265 + { 266 + return int32_ctz_check_for_zero_arg((uint32_t) v); 267 + } 268 + 269 + intnat caml_int32_clz_nonzero_unboxed_to_untagged(int32_t v) 270 + { 271 + return int32_clz((uint32_t) v); 272 + } 273 + 274 + intnat caml_int32_ctz_nonzero_unboxed_to_untagged(int32_t v) 275 + { 276 + return int32_ctz((uint32_t) v); 277 + } 278 + 279 + intnat caml_int32_popcnt_unboxed_to_untagged(int32_t v) 280 + { 281 + return int32_popcnt((uint32_t) v); 282 + } 283 + 284 + CAMLprim value caml_int32_clz(value v1) 285 + { 286 + return caml_copy_int32(caml_int32_clz_unboxed_to_untagged(Int32_val(v1))); 287 + } 288 + 289 + CAMLprim value caml_int32_ctz(value v1) 290 + { 291 + return caml_copy_int32(caml_int32_ctz_unboxed_to_untagged(Int32_val(v1))); 292 + } 293 + 294 + CAMLprim value caml_int32_popcnt(value v1) 295 + { 296 + return caml_copy_int32(caml_int32_popcnt_unboxed_to_untagged(Int32_val(v1))); 297 + } 298 + 299 + int32_t caml_int32_shift_left_by_int32_unboxed(int32_t v1, int32_t v2) 300 + { 301 + return v1 << v2; 302 + } 303 + 304 + int32_t caml_int32_shift_right_by_int32_unboxed(int32_t v1, int32_t v2) 305 + { 306 + return v1 >> v2; 307 + } 308 + 309 + int32_t caml_int32_shift_right_logical_by_int32_unboxed(int32_t v1, int32_t v2) 310 + { 311 + return ((uint32_t) v1 >> v2); 312 + } 313 + 314 + CAMLprim value caml_int32_shift_left_by_int32(value v1, value v2) 315 + { 316 + int32_t res = caml_int32_shift_left_by_int32_unboxed(Int32_val(v1), 317 + Int32_val(v2)); 318 + return caml_copy_int32(res); 319 + } 320 + 321 + CAMLprim value caml_int32_shift_right_by_int32(value v1, value v2) 322 + { 323 + int32_t res = caml_int32_shift_right_by_int32_unboxed(Int32_val(v1), 324 + Int32_val(v2)); 325 + return caml_copy_int32(res); 326 + } 327 + 328 + CAMLprim value caml_int32_shift_right_logical_by_int32(value v1, value v2) 329 + { 330 + int32_t res = caml_int32_shift_right_logical_by_int32_unboxed(Int32_val(v1), 331 + Int32_val(v2)); 332 + return caml_copy_int32(res); 333 + } 334 + 335 + intnat caml_int64_clz_unboxed_to_untagged(int64_t v) 336 + { 337 + return int64_clz_check_for_zero_arg((uint64_t) v); 338 + } 339 + 340 + intnat caml_int64_ctz_unboxed_to_untagged(int64_t v) 341 + { 342 + return int64_ctz_check_for_zero_arg((uint64_t) v); 343 + } 344 + 345 + intnat caml_int64_clz_nonzero_unboxed_to_untagged(int64_t v) 346 + { 347 + return int64_clz((uint64_t) v); 348 + } 349 + 350 + intnat caml_int64_ctz_nonzero_unboxed_to_untagged(int64_t v) 351 + { 352 + return int64_ctz((uint64_t) v); 353 + } 354 + 355 + intnat caml_int64_popcnt_unboxed_to_untagged(int64_t v) 356 + { 357 + return int64_popcnt((uint64_t) v); 358 + } 359 + 360 + CAMLprim value caml_int64_clz(value v1) 361 + { 362 + return caml_copy_int64(caml_int64_clz_unboxed_to_untagged(Int64_val(v1))); 363 + } 364 + 365 + CAMLprim value caml_int64_ctz(value v1) 366 + { 367 + return caml_copy_int64(caml_int64_ctz_unboxed_to_untagged(Int64_val(v1))); 368 + } 369 + 370 + CAMLprim value caml_int64_popcnt(value v1) 371 + { 372 + return caml_copy_int64(int64_popcnt(Int64_val(v1))); 373 + } 374 + 375 + int64_t caml_int64_shift_left_by_int64_unboxed(int64_t v1, int64_t v2) 376 + { 377 + return v1 << v2; 378 + } 379 + 380 + int64_t caml_int64_shift_right_by_int64_unboxed(int64_t v1, int64_t v2) 381 + { 382 + return v1 >> v2; 383 + } 384 + 385 + int64_t caml_int64_shift_right_logical_by_int64_unboxed(int64_t v1, int64_t v2) 386 + { 387 + return ((uint64_t) v1 >> v2); 388 + } 389 + 390 + CAMLprim value caml_int64_shift_left_by_int64(value v1, value v2) 391 + { 392 + int64_t res = caml_int64_shift_left_by_int64_unboxed(Int64_val(v1), 393 + Int64_val(v2)); 394 + return caml_copy_int64(res); 395 + } 396 + 397 + CAMLprim value caml_int64_shift_right_by_int64(value v1, value v2) 398 + { 399 + int64_t res = caml_int64_shift_right_by_int64_unboxed(Int64_val(v1), 400 + Int64_val(v2)); 401 + return caml_copy_int64(res); 402 + } 403 + 404 + CAMLprim value caml_int64_shift_right_logical_by_int64(value v1, value v2) 405 + { 406 + int64_t res = caml_int64_shift_right_logical_by_int64_unboxed(Int64_val(v1), 407 + Int64_val(v2)); 408 + return caml_copy_int64(res); 409 + } 410 + 411 + int caml_nativeint_clz_unboxed_to_untagged(intnat v) 412 + { 413 + #ifdef ARCH_SIXTYFOUR 414 + return int64_clz_check_for_zero_arg((uint64_t) v); 415 + #else 416 + return int32_clz_check_for_zero_arg((uint32_t) v); 417 + #endif 418 + } 419 + 420 + intnat caml_nativeint_ctz_unboxed_to_untagged(intnat v) 421 + { 422 + #ifdef ARCH_SIXTYFOUR 423 + return int64_ctz_check_for_zero_arg((uint64_t) v); 424 + #else 425 + return int32_ctz_check_for_zero_arg((uint32_t) v); 426 + #endif 427 + } 428 + 429 + int caml_nativeint_clz_nonzero_unboxed_to_untagged(intnat v) 430 + { 431 + #ifdef ARCH_SIXTYFOUR 432 + return int64_clz((uint64_t) v); 433 + #else 434 + return int32_clz((uint32_t) v); 435 + #endif 436 + } 437 + 438 + intnat caml_nativeint_ctz_nonzero_unboxed_to_untagged(intnat v) 439 + { 440 + #ifdef ARCH_SIXTYFOUR 441 + return int64_ctz((uint64_t) v); 442 + #else 443 + return int32_ctz((uint32_t) v); 444 + #endif 445 + } 446 + 447 + intnat caml_nativeint_popcnt_unboxed_to_untagged(intnat v) 448 + { 449 + #ifdef ARCH_SIXTYFOUR 450 + return int64_popcnt((uint64_t) v); 451 + #else 452 + return int32_popcnt((uint32_t) v); 453 + #endif 454 + } 455 + 456 + CAMLprim value caml_nativeint_clz(value v1) 457 + { 458 + return caml_copy_nativeint(caml_nativeint_clz_unboxed_to_untagged(Nativeint_val(v1))); 459 + } 460 + 461 + CAMLprim value caml_nativeint_ctz(value v1) 462 + { 463 + return caml_copy_nativeint(caml_nativeint_ctz_unboxed_to_untagged(Nativeint_val(v1))); 464 + } 465 + 466 + CAMLprim value caml_nativeint_popcnt(value v1) 467 + { 468 + return caml_copy_nativeint(caml_nativeint_popcnt_unboxed_to_untagged(Nativeint_val(v1))); 469 + } 470 + 471 + intnat caml_nativeint_shift_left_by_nativeint_unboxed(intnat v1, intnat v2) 472 + { 473 + return v1 << v2; 474 + } 475 + 476 + intnat caml_nativeint_shift_right_by_nativeint_unboxed(intnat v1, intnat v2) 477 + { 478 + return v1 >> v2; 479 + } 480 + 481 + intnat caml_nativeint_shift_right_logical_by_nativeint_unboxed(intnat v1, intnat v2) 482 + { 483 + return ((uintnat) v1 >> v2); 484 + } 485 + 486 + CAMLprim value caml_nativeint_shift_left_by_nativeint(value v1, value v2) 487 + { 488 + intnat res = caml_nativeint_shift_left_by_nativeint_unboxed(Nativeint_val(v1), 489 + Nativeint_val(v2)); 490 + return caml_copy_nativeint(res); 491 + } 492 + 493 + CAMLprim value caml_nativeint_shift_right_by_nativeint(value v1, value v2) 494 + { 495 + intnat res = caml_nativeint_shift_right_by_nativeint_unboxed(Nativeint_val(v1), 496 + Nativeint_val(v2)); 497 + return caml_copy_nativeint(res); 498 + } 499 + 500 + CAMLprim value caml_nativeint_shift_right_logical_by_nativeint(value v1, value v2) 501 + { 502 + intnat res = caml_nativeint_shift_right_logical_by_nativeint_unboxed(Nativeint_val(v1), 503 + Nativeint_val(v2)); 504 + return caml_copy_nativeint(res); 505 + }
+87
vendor/opam/ocaml_intrinsics_kernel/src/naive_ints.ml
··· 1 + module type Intlike = sig 2 + type t 3 + 4 + val logand : t -> t -> t 5 + val zero : t 6 + val one : t 7 + val equal : t -> t -> bool 8 + val compare : t -> t -> int 9 + val shift_right : t -> int -> t 10 + val shift_right_logical : t -> int -> t 11 + val shift_left : t -> int -> t 12 + val bitwidth : t 13 + val to_int : t -> int 14 + val of_int : int -> t 15 + end 16 + 17 + module type S = sig 18 + type t 19 + 20 + (** See documentation of [Int]. *) 21 + val count_leading_zeros : t -> t 22 + 23 + val count_set_bits : t -> t 24 + val count_trailing_zeros : t -> t 25 + val shift_left : t -> t -> t 26 + val shift_right : t -> t -> t 27 + val shift_right_logical : t -> t -> t 28 + end 29 + 30 + module Make (Int : Intlike) : S with type t = Int.t = struct 31 + type t = Int.t 32 + 33 + let least_significant_bit n = Int.logand n Int.one 34 + 35 + let is_least_significant_bit_set n = 36 + let lsb = least_significant_bit n in 37 + if Int.equal lsb Int.one 38 + then true 39 + else if Int.equal lsb Int.zero 40 + then false 41 + else assert false 42 + ;; 43 + 44 + let is_most_significant_bit_set n = if Int.compare n Int.zero < 0 then true else false 45 + 46 + let count_trailing_zeros n = 47 + let rec loop ~acc ~mask = 48 + if is_least_significant_bit_set mask 49 + then acc 50 + else ( 51 + let mask = Int.shift_right_logical mask 1 in 52 + let acc = acc + 1 in 53 + loop ~mask ~acc) 54 + in 55 + if Int.equal n Int.zero then Int.bitwidth else loop ~acc:0 ~mask:n |> Int.of_int 56 + ;; 57 + 58 + let count_leading_zeros n = 59 + let rec loop ~acc ~mask = 60 + if is_most_significant_bit_set mask 61 + then acc 62 + else ( 63 + let mask = Int.shift_left mask 1 in 64 + let acc = acc + 1 in 65 + loop ~mask ~acc) 66 + in 67 + if Int.equal n Int.zero then Int.bitwidth else loop ~acc:0 ~mask:n |> Int.of_int 68 + ;; 69 + 70 + let count_set_bits n = 71 + let rec loop ~acc ~mask = 72 + if Int.equal mask Int.zero 73 + then acc 74 + else ( 75 + let acc = if is_least_significant_bit_set mask then acc + 1 else acc in 76 + let mask = Int.shift_right_logical mask 1 in 77 + loop ~mask ~acc) 78 + in 79 + loop ~acc:0 ~mask:n |> Int.of_int 80 + ;; 81 + 82 + let shift_mask = (Int.bitwidth |> Int.to_int) - 1 |> Int.of_int 83 + let to_int_shift y = Int.logand y shift_mask |> Int.to_int 84 + let shift_left x y = Int.shift_left x (to_int_shift y) 85 + let shift_right x y = Int.shift_right x (to_int_shift y) 86 + let shift_right_logical x y = Int.shift_right_logical x (to_int_shift y) 87 + end
+30
vendor/opam/ocaml_intrinsics_kernel/src/naive_ints.mli
··· 1 + module type Intlike = sig 2 + type t 3 + 4 + val logand : t -> t -> t 5 + val zero : t 6 + val one : t 7 + val equal : t -> t -> bool 8 + val compare : t -> t -> int 9 + val shift_right : t -> int -> t 10 + val shift_right_logical : t -> int -> t 11 + val shift_left : t -> int -> t 12 + val bitwidth : t 13 + val to_int : t -> int 14 + val of_int : int -> t 15 + end 16 + 17 + module type S = sig 18 + type t 19 + 20 + (** See documentation of [Int]. *) 21 + val count_leading_zeros : t -> t 22 + 23 + val count_set_bits : t -> t 24 + val count_trailing_zeros : t -> t 25 + val shift_left : t -> t -> t 26 + val shift_right : t -> t -> t 27 + val shift_right_logical : t -> t -> t 28 + end 29 + 30 + module Make (I : Intlike) : S with type t = I.t
+125
vendor/opam/ocaml_intrinsics_kernel/src/nativeint.ml
··· 1 + module Stubs = struct 2 + let available = Common.available 3 + 4 + (** [count_leading_zeros n] returns the number of most-significant zero bits before the 5 + most significant set bit in [n]. If [n] is 0, the result is the number of bits in 6 + [n], that is 32 or 64, depending on the target. *) 7 + external count_leading_zeros 8 + : (nativeint[@unboxed] [@local_opt]) 9 + -> (nativeint[@unboxed]) 10 + = "caml_nativeint_clz" "caml_nativeint_clz_unboxed_to_untagged" 11 + [@@noalloc] [@@builtin] [@@no_effects] [@@no_coeffects] 12 + 13 + (** Same as [count_leading_zeros] except if the argument is zero, then the result is 14 + undefined. Emits more efficient code. *) 15 + external count_leading_zeros_nonzero_arg 16 + : (nativeint[@unboxed] [@local_opt]) 17 + -> (nativeint[@unboxed]) 18 + = "caml_nativeint_clz" "caml_nativeint_clz_nonzero_unboxed_to_untagged" 19 + [@@noalloc] [@@builtin] [@@no_effects] [@@no_coeffects] 20 + 21 + (** [count_trailing_zeros n] returns the number of least-significant zero bits before 22 + the least significant set bit in [n]. If [n] is 0, the result is the number of bits 23 + in [n], that is 32 or 64, depending on the target. *) 24 + external count_trailing_zeros 25 + : (nativeint[@unboxed] [@local_opt]) 26 + -> (nativeint[@unboxed]) 27 + = "caml_nativeint_ctz" "caml_nativeint_ctz_unboxed_to_untagged" 28 + [@@noalloc] [@@builtin] [@@no_effects] [@@no_coeffects] 29 + 30 + (** Same as [count_trailing_zeros] except if the argument is zero, then the result is 31 + undefined. Emits more efficient code. *) 32 + external count_trailing_zeros_nonzero_arg 33 + : (nativeint[@unboxed] [@local_opt]) 34 + -> (nativeint[@unboxed]) 35 + = "caml_nativeint_ctz" "caml_nativeint_ctz_nonzero_unboxed_to_untagged" 36 + [@@noalloc] [@@builtin] [@@no_effects] [@@no_coeffects] 37 + 38 + (** [count_set_bits n] returns the number of bits that are 1 in [n]. *) 39 + external count_set_bits 40 + : (nativeint[@unboxed] [@local_opt]) 41 + -> (nativeint[@unboxed]) 42 + = "caml_nativeint_popcnt" "caml_nativeint_popcnt_unboxed_to_untagged" 43 + [@@noalloc] [@@builtin] [@@no_effects] [@@no_coeffects] 44 + 45 + external shift_left 46 + : (nativeint[@local_opt]) 47 + -> (nativeint[@local_opt]) 48 + -> (nativeint[@local_opt]) 49 + = "caml_nativeint_shift_left_by_nativeint" 50 + "caml_nativeint_shift_left_by_nativeint_unboxed" 51 + [@@noalloc] (* [@@builtin] *) [@@no_effects] [@@no_coeffects] [@@unboxed] 52 + 53 + external shift_right 54 + : (nativeint[@local_opt]) 55 + -> (nativeint[@local_opt]) 56 + -> (nativeint[@local_opt]) 57 + = "caml_nativeint_shift_right_by_nativeint" 58 + "caml_nativeint_shift_right_by_nativeint_unboxed" 59 + [@@noalloc] (* [@@builtin] *) [@@no_effects] [@@no_coeffects] [@@unboxed] 60 + 61 + external shift_right_logical 62 + : (nativeint[@local_opt]) 63 + -> (nativeint[@local_opt]) 64 + -> (nativeint[@local_opt]) 65 + = "caml_nativeint_shift_right_logical_by_nativeint" 66 + "caml_nativeint_shift_right_logical_by_nativeint_unboxed" 67 + [@@noalloc] (* [@@builtin] *) [@@no_effects] [@@no_coeffects] [@@unboxed] 68 + end 69 + 70 + module Naive = Naive_ints.Make (struct 71 + include Stdlib.Nativeint 72 + 73 + external compare : t -> t -> int = "%compare" 74 + external equal : t -> t -> bool = "%equal" 75 + 76 + let bitwidth = Sys.word_size |> of_int 77 + end) 78 + 79 + let[@inline always] count_leading_zeros n = 80 + match Stubs.available with 81 + | true -> Stubs.count_leading_zeros n 82 + | false -> Naive.count_leading_zeros n 83 + ;; 84 + 85 + let[@inline always] count_leading_zeros_nonzero_arg n = 86 + match Stubs.available with 87 + | true -> Stubs.count_leading_zeros_nonzero_arg n 88 + | false -> Naive.count_leading_zeros n 89 + ;; 90 + 91 + let[@inline always] count_trailing_zeros n = 92 + match Stubs.available with 93 + | true -> Stubs.count_trailing_zeros n 94 + | false -> Naive.count_trailing_zeros n 95 + ;; 96 + 97 + let[@inline always] count_trailing_zeros_nonzero_arg n = 98 + match Stubs.available with 99 + | true -> Stubs.count_trailing_zeros_nonzero_arg n 100 + | false -> Naive.count_trailing_zeros n 101 + ;; 102 + 103 + let[@inline always] count_set_bits n = 104 + match Stubs.available with 105 + | true -> Stubs.count_set_bits n 106 + | false -> Naive.count_set_bits n 107 + ;; 108 + 109 + let[@inline always] shift_left x y = 110 + match Stubs.available with 111 + | true -> Stubs.shift_left x y 112 + | false -> Naive.shift_left x y 113 + ;; 114 + 115 + let[@inline always] shift_right x y = 116 + match Stubs.available with 117 + | true -> Stubs.shift_right x y 118 + | false -> Naive.shift_right x y 119 + ;; 120 + 121 + let[@inline always] shift_right_logical x y = 122 + match Stubs.available with 123 + | true -> Stubs.shift_right_logical x y 124 + | false -> Naive.shift_right_logical x y 125 + ;;
+47
vendor/opam/ocaml_intrinsics_kernel/src/nativeint.mli
··· 1 + (** [count_leading_zeros n] returns the number of most-significant zero bits before the 2 + most significant set bit in [n]. If [n] is 0, the result is the number of bits in [n], 3 + that is 32 or 64, depending on the target. *) 4 + val count_leading_zeros : nativeint -> nativeint 5 + 6 + (** Same as [count_leading_zeros] except if the argument is zero, then the result is 7 + undefined. Emits more efficient code. 8 + 9 + This is no longer needed when using an flambda-backend compiler, which translates 10 + [count_leading_zeros] to LZCNT by default (amd64). *) 11 + val count_leading_zeros_nonzero_arg : nativeint -> nativeint 12 + 13 + (** [count_trailing_zeros n] returns the number of least-significant zero bits before the 14 + least significant set bit in [n]. If [n] is 0, the result is the number of bits in 15 + [n], that is 32 or 64, depending on the target. *) 16 + val count_trailing_zeros : nativeint -> nativeint 17 + 18 + (** Same as [count_trailing_zeros] except if the argument is zero, then the result is 19 + undefined. Emits more efficient code. 20 + 21 + This is no longer needed when using an flambda-backend compiler, which translates 22 + [count_trailing_zeros] to TZCNT by default (amd64). *) 23 + val count_trailing_zeros_nonzero_arg : nativeint -> nativeint 24 + 25 + (** [count_set_bits n] returns the number of bits that are 1 in [n]. *) 26 + val count_set_bits : nativeint -> nativeint 27 + 28 + (** Shift operations below differ from the corresponding [Stdlib.Nativeint.shift_*] 29 + operations in two ways: 30 + (a) shift count (second argument) is the same type as the first argument, allowing 31 + unboxed types to be used as counts. 32 + (b) the operations are defined for arbitrary shift counts and rely on the hardware to 33 + mask the shift to [bitwidth-1] bits, where [bitwidth] is determined by the type of 34 + the first argument. *) 35 + 36 + (** [shift_left x y] shifts [x] to the left by [y & (bitwidth-1)] bits. *) 37 + val shift_left : nativeint -> nativeint -> nativeint 38 + 39 + (** [Nativeint.shift_right x y] shifts [x] to the right by [y] bits. This is an arithmetic 40 + shift: the sign bit of [x] is replicated and inserted in the vacated bits. *) 41 + val shift_right : nativeint -> nativeint -> nativeint 42 + 43 + (** [Nativeint.shift_right_logical x y] shifts [x] to the right by [y] bits. This is a 44 + logical shift: zeroes are inserted in the vacated bits regardless of the sign of [x]. *) 45 + val shift_right_logical : nativeint -> nativeint -> nativeint 46 + 47 + module Naive : Naive_ints.S with type t = nativeint
+8
vendor/opam/ocaml_intrinsics_kernel/src/ocaml_intrinsics_kernel.ml
··· 1 + module Common = Common 2 + module Conditional = Conditional 3 + module Float = Float 4 + module Int = Int 5 + module Int32 = Int32 6 + module Int64 = Int64 7 + module Naive_ints = Naive_ints 8 + module Nativeint = Nativeint
+23
vendor/opam/ocaml_intrinsics_kernel/src/runtime.js
··· 1 + //Provides: caml_csel_value 2 + function caml_csel_value(v_cond, v_true, v_false) { 3 + if (v_cond) 4 + return v_true; 5 + else 6 + return v_false; 7 + } 8 + 9 + //Provides: caml_sse2_float64_min_bytecode 10 + function caml_sse2_float64_min_bytecode(x, y) { 11 + return x < y ? x : y; 12 + } 13 + 14 + //Provides: caml_sse2_float64_max_bytecode 15 + function caml_sse2_float64_max_bytecode(x, y) { 16 + return x > y ? x : y; 17 + } 18 + 19 + //Requires: caml_int64_of_float 20 + //Provides: caml_sse2_cast_float64_int64_bytecode 21 + function caml_sse2_cast_float64_int64_bytecode(x) { 22 + return caml_int64_of_float(Math.round(x)); 23 + }
+34
vendor/opam/ocaml_intrinsics_kernel/src/runtime.wat
··· 1 + (module 2 + (import "env" "Double_val" 3 + (func $Double_val (param (ref eq)) (result f64))) 4 + (import "env" "caml_copy_int64" 5 + (func $caml_copy_int64 (param i64) (result (ref eq)))) 6 + 7 + (type $float (struct (field f64))) 8 + (func $unbox_float 9 + (param $f (ref eq)) (result f64) 10 + (struct.get $float 0 (ref.cast (ref $float) (local.get $f)))) 11 + 12 + (func (export "caml_csel_value") 13 + (param $cond (ref eq)) (param $true (ref eq)) (param $false (ref eq)) 14 + (result (ref eq)) 15 + (select (local.get $true) (local.get $false) 16 + (i31.get_s (ref.cast (ref i31) (local.get $cond))))) 17 + 18 + (func (export "caml_sse2_float64_min_bytecode") 19 + (param $x (ref eq)) (param $y (ref eq)) (result (ref eq)) 20 + (select (local.get $x) (local.get $y) 21 + (f64.lt (call $Double_val (local.get $x)) 22 + (call $Double_val (local.get $y))))) 23 + 24 + (func (export "caml_sse2_float64_max_bytecode") 25 + (param $x (ref eq)) (param $y (ref eq)) (result (ref eq)) 26 + (select (local.get $x) (local.get $y) 27 + (f64.gt (call $Double_val (local.get $x)) 28 + (call $Double_val (local.get $y))))) 29 + 30 + (func (export "caml_sse2_cast_float64_int64_bytecode") 31 + (param $f (ref eq)) (result (ref eq)) 32 + (call $caml_copy_int64 33 + (i64.trunc_sat_f64_s (f64.nearest (call $unbox_float (local.get $f)))))) 34 + )
+20
vendor/opam/ocaml_intrinsics_kernel/test/dune
··· 1 + (library 2 + (name ocaml_intrinsics_kernel_test) 3 + (preprocessor_deps config.h) 4 + (flags :standard -extension layouts) 5 + (libraries unboxed.int32_u unboxed.int64_u unboxed.nativeint_u 6 + ocaml_intrinsics_kernel ppx_bench.runtime-lib ppx_expect.runtime 7 + ppx_module_timer.runtime stdio) 8 + (js_of_ocaml 9 + (javascript_files test_stubs.js)) 10 + (preprocess 11 + (pps ppx_jane ppx_optcomp)) 12 + (wasm_of_ocaml 13 + (javascript_files test_stubs.js) 14 + (wasm_files test_stubs.wat))) 15 + 16 + (rule 17 + (targets config.h) 18 + (deps) 19 + (action 20 + (bash "cp %{lib:jst-config:config.h} .")))
+46
vendor/opam/ocaml_intrinsics_kernel/test/import.ml
··· 1 + open Base 2 + open Stdio 3 + 4 + module type Hum = sig 5 + type t 6 + 7 + val to_string_hum : ?delimiter:char -> t -> string 8 + end 9 + 10 + module Hum_string (H : Hum) = struct 11 + include H 12 + 13 + let to_string = to_string_hum 14 + end 15 + 16 + let test 17 + (type i o) 18 + (module Input : Hum with type t = i) 19 + (module Output : Stringable.S with type t = o) 20 + ~name 21 + ~op 22 + x 23 + = 24 + let module Input = Hum_string (Input) in 25 + print_endline [%string "%{name} %{x#Input} = %{op x#Output}"] 26 + ;; 27 + 28 + let test_shifts 29 + (type t) 30 + (module Input : Hum with type t = t) 31 + (module Shift : Hum with type t = t) 32 + ~name 33 + ~(op : t -> t -> t) 34 + ~(expected_op : t -> t -> t) 35 + x 36 + y 37 + = 38 + let module Input = Hum_string (Input) in 39 + let module Shift = Hum_string (Shift) in 40 + let expected = expected_op x y in 41 + let res = op x y in 42 + print_endline [%string "%{x#Input} %{name} by %{y#Shift} ="]; 43 + print_endline [%string.global "%{res#Input}"]; 44 + if Stdlib.compare res expected <> 0 45 + then print_endline [%string "%{expected#Input} expected"] 46 + ;;
+7
vendor/opam/ocaml_intrinsics_kernel/test/ocaml_intrinsics_kernel_test.ml
··· 1 + module Import = Import 2 + module Test_clz = Test_clz 3 + module Test_csel = Test_csel 4 + module Test_ctz = Test_ctz 5 + module Test_float = Test_float 6 + module Test_popcnt = Test_popcnt 7 + module Test_shifts = Test_shifts
+197
vendor/opam/ocaml_intrinsics_kernel/test/test_clz.ml
··· 1 + open Base 2 + open Import 3 + module I = Ocaml_intrinsics_kernel 4 + 5 + let%expect_test "clz int64" = 6 + let open Int64 in 7 + let numbers = 8 + [ 0L (* Int.num_bits *) 9 + ; 1L (* Int.num_bits - 1 *) 10 + ; 7L (* Int.num_bits - 3 *) 11 + ; max_value 12 + ; min_value 13 + ; -1L 14 + ] 15 + in 16 + let f = 17 + test (module Int64.Hex) (module Int64) ~op:I.Int64.count_leading_zeros ~name:"clz" 18 + in 19 + List.iter ~f numbers; 20 + [%expect 21 + {| 22 + clz 0x0 = 64 23 + clz 0x1 = 63 24 + clz 0x7 = 61 25 + clz 0x7fff_ffff_ffff_ffff = 1 26 + clz -0x8000_0000_0000_0000 = 0 27 + clz -0x1 = 0 28 + |}] 29 + ;; 30 + 31 + let%expect_test "clz int32" = 32 + let open Int32 in 33 + let numbers = 34 + [ 0l (* Int.num_bits *) 35 + ; 1l (* Int.num_bits - 1 *) 36 + ; 7l (* Int.num_bits - 3 *) 37 + ; max_value 38 + ; min_value 39 + ; -1l 40 + ] 41 + in 42 + let f = 43 + test (module Int32.Hex) (module Int32) ~op:I.Int32.count_leading_zeros ~name:"clz" 44 + in 45 + List.iter ~f numbers; 46 + [%expect 47 + {| 48 + clz 0x0 = 32 49 + clz 0x1 = 31 50 + clz 0x7 = 29 51 + clz 0x7fff_ffff = 1 52 + clz -0x8000_0000 = 0 53 + clz -0x1 = 0 54 + |}] 55 + ;; 56 + 57 + module%test [@tags "64-bits-only"] Arch64 = struct 58 + let%expect_test "clz int" = 59 + let open Int in 60 + let numbers = 61 + [ 0 (* Int.num_bits *) 62 + ; 1 (* Int.num_bits - 1 *) 63 + ; 7 (* Int.num_bits - 3 *) 64 + ; max_value 65 + ; min_value 66 + ; -1 67 + ] 68 + in 69 + let f = 70 + test (module Int.Hex) (module Int) ~op:I.Int.count_leading_zeros ~name:"clz" 71 + in 72 + List.iter ~f numbers; 73 + [%expect 74 + {| 75 + clz 0x0 = 63 76 + clz 0x1 = 62 77 + clz 0x7 = 60 78 + clz 0x3fff_ffff_ffff_ffff = 1 79 + clz -0x4000_0000_0000_0000 = 0 80 + clz -0x1 = 0 81 + |}]; 82 + let f = 83 + test (module Int.Hex) (module Int) ~op:I.Int.count_leading_zeros2 ~name:"clz2" 84 + in 85 + List.iter ~f numbers; 86 + [%expect 87 + {| 88 + clz2 0x0 = 63 89 + clz2 0x1 = 62 90 + clz2 0x7 = 60 91 + clz2 0x3fff_ffff_ffff_ffff = 1 92 + clz2 -0x4000_0000_0000_0000 = 0 93 + clz2 -0x1 = 0 94 + |}] 95 + ;; 96 + 97 + let%expect_test "clz nativeint" = 98 + let open Nativeint in 99 + let numbers = 100 + [ 0n (* Int.num_bits *) 101 + ; 1n (* Int.num_bits - 1 *) 102 + ; 7n (* Int.num_bits - 3 *) 103 + ; max_value 104 + ; min_value 105 + ; -1n 106 + ] 107 + in 108 + let f = 109 + test 110 + (module Nativeint.Hex) 111 + (module Nativeint) 112 + ~op:I.Nativeint.count_leading_zeros 113 + ~name:"clz" 114 + in 115 + List.iter ~f numbers; 116 + [%expect 117 + {| 118 + clz 0x0 = 64 119 + clz 0x1 = 63 120 + clz 0x7 = 61 121 + clz 0x7fff_ffff_ffff_ffff = 1 122 + clz -0x8000_0000_0000_0000 = 0 123 + clz -0x1 = 0 124 + |}] 125 + ;; 126 + end 127 + 128 + module%test [@tags "32-bits-only", "js-only"] Arch32 = struct 129 + let%expect_test "clz int" = 130 + let open Int in 131 + let numbers = 132 + [ 0 (* Int.num_bits *) 133 + ; 1 (* Int.num_bits - 1 *) 134 + ; 7 (* Int.num_bits - 3 *) 135 + ; max_value 136 + ; min_value 137 + ; -1 138 + ] 139 + in 140 + let f = 141 + test (module Int.Hex) (module Int) ~op:I.Int.count_leading_zeros ~name:"clz" 142 + in 143 + List.iter ~f numbers; 144 + [%expect 145 + {| 146 + clz 0x0 = 31 147 + clz 0x1 = 30 148 + clz 0x7 = 28 149 + clz 0x3fff_ffff = 1 150 + clz -0x4000_0000 = 0 151 + clz -0x1 = 0 152 + |}]; 153 + let f = 154 + test (module Int.Hex) (module Int) ~op:I.Int.count_leading_zeros2 ~name:"clz2" 155 + in 156 + List.iter ~f numbers; 157 + [%expect 158 + {| 159 + clz2 0x0 = 31 160 + clz2 0x1 = 30 161 + clz2 0x7 = 28 162 + clz2 0x3fff_ffff = 1 163 + clz2 -0x4000_0000 = 0 164 + clz2 -0x1 = 0 165 + |}] 166 + ;; 167 + 168 + let%expect_test "clz nativeint" = 169 + let open Nativeint in 170 + let numbers = 171 + [ 0n (* Int.num_bits *) 172 + ; 1n (* Int.num_bits - 1 *) 173 + ; 7n (* Int.num_bits - 3 *) 174 + ; max_value 175 + ; min_value 176 + ; -1n 177 + ] 178 + in 179 + let f = 180 + test 181 + (module Nativeint.Hex) 182 + (module Nativeint) 183 + ~op:I.Nativeint.count_leading_zeros 184 + ~name:"clz" 185 + in 186 + List.iter ~f numbers; 187 + [%expect 188 + {| 189 + clz 0x0 = 32 190 + clz 0x1 = 31 191 + clz 0x7 = 29 192 + clz 0x7fff_ffff = 1 193 + clz -0x8000_0000 = 0 194 + clz -0x1 = 0 195 + |}] 196 + ;; 197 + end
+1
vendor/opam/ocaml_intrinsics_kernel/test/test_clz.mli
··· 1 + (*_ This signature is deliberately empty. *)
+273
vendor/opam/ocaml_intrinsics_kernel/test/test_csel.ml
··· 1 + open Base 2 + open Stdio 3 + module I = Ocaml_intrinsics_kernel.Conditional 4 + 5 + let%expect_test "csel int" = 6 + let inputs = [ 0; 1; 4; 6; 5 ] in 7 + List.iter inputs ~f:(fun a -> 8 + let expect = if a % 2 = 0 then a else a + 1 in 9 + let actual = I.select_value (a % 2 = 0) a (a + 1) in 10 + printf "%d %d\n" expect actual); 11 + [%expect 12 + {| 13 + 0 0 14 + 2 2 15 + 4 4 16 + 6 6 17 + 6 6 18 + |}] 19 + ;; 20 + 21 + let%expect_test "csel max int value" = 22 + let inputs = [ 0, 1; 4, 5 ] in 23 + List.iter inputs ~f:(fun (a, b) -> 24 + let expect = if a > b then a else b in 25 + let actual = I.select_value (a > b) a b in 26 + printf "%d %d\n" expect actual); 27 + [%expect 28 + {| 29 + 1 1 30 + 5 5 31 + |}] 32 + ;; 33 + 34 + let%expect_test "csel max float value" = 35 + let inputs = [ 0.5, Float.neg_infinity; 0.0, 0.1; Float.nan, 5.0 ] in 36 + List.iter inputs ~f:(fun (a, b) -> 37 + let expect = if Float.(a > b) then a else b in 38 + let actual = I.select_value Float.(a > b) a b in 39 + printf "%f %f\n" expect actual); 40 + [%expect 41 + {| 42 + 0.500000 0.500000 43 + 0.100000 0.100000 44 + 5.000000 5.000000 45 + |}] 46 + ;; 47 + 48 + let%expect_test "csel max int untagged" = 49 + let inputs = [ 0, 1; 4, 5 ] in 50 + List.iter inputs ~f:(fun (a, b) -> 51 + let expect = if a > b then a else b in 52 + let actual = I.select_int (a > b) a b in 53 + printf "%d %d\n" expect actual); 54 + [%expect 55 + {| 56 + 1 1 57 + 5 5 58 + |}] 59 + ;; 60 + 61 + let%expect_test "csel max int64 unboxed" = 62 + let inputs = [ 0L, 1L; 4L, 5L; Int64.max_value, Int64.min_value ] in 63 + List.iter inputs ~f:(fun (a, b) -> 64 + let expect = if Int64.(a > b) then a else b in 65 + let actual = I.select_int64 Int64.(a > b) a b in 66 + printf "%Ld %Ld\n" expect actual); 67 + [%expect 68 + {| 69 + 1 1 70 + 5 5 71 + 9223372036854775807 9223372036854775807 72 + |}] 73 + ;; 74 + 75 + let%expect_test "csel max int64#" = 76 + let inputs = [ 0L, 1L; 4L, 5L; Int64.max_value, Int64.min_value ] in 77 + List.iter inputs ~f:(fun (a, b) -> 78 + let a = Int64_u.of_int64 a in 79 + let b = Int64_u.of_int64 b in 80 + let expect = if Int64_u.(a > b) then a else b in 81 + let actual = I.Unboxed.select_int64 Int64_u.(a > b) a b in 82 + printf "%Ld %Ld\n" (Int64_u.to_int64 expect) (Int64_u.to_int64 actual)); 83 + [%expect 84 + {| 85 + 1 1 86 + 5 5 87 + 9223372036854775807 9223372036854775807 88 + |}] 89 + ;; 90 + 91 + let%expect_test "csel max int32 unboxed" = 92 + let inputs = [ 0l, 1l; 4l, 5l; Int32.max_value, Int32.min_value ] in 93 + List.iter inputs ~f:(fun (a, b) -> 94 + let expect = if Int32.(a > b) then a else b in 95 + let actual = I.select_int32 Int32.(a > b) a b in 96 + printf "%ld %ld\n" expect actual); 97 + [%expect 98 + {| 99 + 1 1 100 + 5 5 101 + 2147483647 2147483647 102 + |}] 103 + ;; 104 + 105 + let%expect_test "csel max int32#" = 106 + let inputs = [ 0l, 1l; 4l, 5l; Int32.max_value, Int32.min_value ] in 107 + List.iter inputs ~f:(fun (a, b) -> 108 + let a = Int32_u.of_int32 a in 109 + let b = Int32_u.of_int32 b in 110 + let expect = if Int32_u.(a > b) then a else b in 111 + let actual = I.Unboxed.select_int32 Int32_u.(a > b) a b in 112 + printf "%ld %ld\n" (Int32_u.to_int32 expect) (Int32_u.to_int32 actual)); 113 + [%expect 114 + {| 115 + 1 1 116 + 5 5 117 + 2147483647 2147483647 118 + |}] 119 + ;; 120 + 121 + module%test [@tags "64-bits-only"] Arch64 = struct 122 + let%expect_test "csel max nativeint unboxed" = 123 + let inputs = [ 0n, 1n; 4n, 5n; Nativeint.max_value, Nativeint.min_value ] in 124 + List.iter inputs ~f:(fun (a, b) -> 125 + let expect = if Nativeint.(a > b) then a else b in 126 + let actual = I.select_nativeint Nativeint.(a > b) a b in 127 + printf "%nd %nd\n" expect actual); 128 + [%expect 129 + {| 130 + 1 1 131 + 5 5 132 + 9223372036854775807 9223372036854775807 133 + |}] 134 + ;; 135 + 136 + let%expect_test "csel max nativeint#" = 137 + let inputs = [ 0n, 1n; 4n, 5n; Nativeint.max_value, Nativeint.min_value ] in 138 + List.iter inputs ~f:(fun (a, b) -> 139 + let a = Nativeint_u.of_nativeint a in 140 + let b = Nativeint_u.of_nativeint b in 141 + let expect = if Nativeint_u.(a > b) then a else b in 142 + let actual = I.Unboxed.select_nativeint Nativeint_u.(a > b) a b in 143 + printf 144 + "%nd %nd\n" 145 + (Nativeint_u.to_nativeint expect) 146 + (Nativeint_u.to_nativeint actual)); 147 + [%expect 148 + {| 149 + 1 1 150 + 5 5 151 + 9223372036854775807 9223372036854775807 152 + |}] 153 + ;; 154 + end 155 + 156 + module%test [@tags "32-bits-only", "js-only"] Arch32 = struct 157 + let%expect_test "csel max nativeint unboxed" = 158 + let inputs = [ 0n, 1n; 4n, 5n; Nativeint.max_value, Nativeint.min_value ] in 159 + List.iter inputs ~f:(fun (a, b) -> 160 + let expect = if Nativeint.(a > b) then a else b in 161 + let actual = I.select_nativeint Nativeint.(a > b) a b in 162 + printf "%nd %nd\n" expect actual); 163 + [%expect 164 + {| 165 + 1 1 166 + 5 5 167 + 2147483647 2147483647 168 + |}] 169 + ;; 170 + 171 + let%expect_test "csel max nativeint#" = 172 + let inputs = [ 0n, 1n; 4n, 5n; Nativeint.max_value, Nativeint.min_value ] in 173 + List.iter inputs ~f:(fun (a, b) -> 174 + let a = Nativeint_u.of_nativeint a in 175 + let b = Nativeint_u.of_nativeint b in 176 + let expect = if Nativeint_u.(a > b) then a else b in 177 + let actual = I.Unboxed.select_nativeint Nativeint_u.(a > b) a b in 178 + printf 179 + "%nd %nd\n" 180 + (Nativeint_u.to_nativeint expect) 181 + (Nativeint_u.to_nativeint actual)); 182 + [%expect 183 + {| 184 + 1 1 185 + 5 5 186 + 2147483647 2147483647 187 + |}] 188 + ;; 189 + end 190 + 191 + let%expect_test "csel sideffects" = 192 + let inputs = [ 0, 1; 5, 4 ] in 193 + List.iter inputs ~f:(fun (a, b) -> 194 + let expect = 195 + if a > b 196 + then ( 197 + printf "hello 0\n"; 198 + a) 199 + else ( 200 + printf "world 0\n"; 201 + b) 202 + in 203 + let actual = 204 + I.select_value 205 + (a > b) 206 + (printf "hello 1\n"; 207 + a) 208 + (printf "world 1\n"; 209 + b) 210 + in 211 + printf "%d %d\n" expect actual); 212 + [%expect 213 + {| 214 + world 0 215 + world 1 216 + hello 1 217 + 1 1 218 + hello 0 219 + world 1 220 + hello 1 221 + 5 5 222 + |}] 223 + ;; 224 + 225 + let%expect_test "min extra moves" = 226 + (* Currently [min] emits extra moves: 227 + * 228 + * actual: 229 + * 230 + * camlT__min_266: 231 + * movq %rax, %rdi 232 + * movq %rbx, %rax 233 + * cmpq %rax, %rdi 234 + * cmovl %rdi, %rax 235 + * ret 236 + * 237 + * [min2] is 238 + * 239 + * camlT__min2_273: 240 + * cmpq %rax, %rbx 241 + * cmovl %rbx, %rax 242 + * ret 243 + * ret *) 244 + let[@inline never] min (x : int) (y : int) = I.select_value (x < y) x y in 245 + let[@inline never] min2 (x : int) (y : int) = I.select_value (y < x) y x in 246 + let inputs = [ 0, 1; 5, 4 ] in 247 + List.iter inputs ~f:(fun (a, b) -> 248 + printf "%d " (min a b); 249 + printf "%d\n" (min2 a b)); 250 + [%expect 251 + {| 252 + 0 0 253 + 4 4 254 + |}] 255 + ;; 256 + 257 + let%expect_test "float deadcode" = 258 + (* Currently [nop_float] emits extra loads, because there is no dead code elimination 259 + * after register allocation: 260 + * 261 + * camlT__nop_float_292: 262 + * movsd (%rbx), %xmm0 263 + * movsd (%rax), %xmm1 264 + * ret *) 265 + let[@inline never] nop_float (x : float) (y : float) : float = 266 + I.select_value Float.(x > y) x x 267 + in 268 + let inputs = 269 + [ 0.5, Float.neg_infinity; 0.0, 0.1; Float.nan, 5.0; Float.infinity, -0.0 ] 270 + in 271 + List.iter inputs ~f:(fun (a, b) -> printf "%f " (nop_float a b)); 272 + [%expect {| 0.500000 0.000000 nan inf |}] 273 + ;;
+1
vendor/opam/ocaml_intrinsics_kernel/test/test_csel.mli
··· 1 + (* blank *)
+145
vendor/opam/ocaml_intrinsics_kernel/test/test_ctz.ml
··· 1 + open Base 2 + open Import 3 + module I = Ocaml_intrinsics_kernel 4 + 5 + let numbers = [ 0 (* Int.num_bits *); 1; 7; 2; 4; 12; 18; -1 ] 6 + 7 + let%expect_test "ctz int64" = 8 + let open Int64 in 9 + let numbers = List.map numbers ~f:of_int in 10 + let f = 11 + test (module Int64.Hex) (module Int64) ~op:I.Int64.count_trailing_zeros ~name:"ctz" 12 + in 13 + List.iter ~f (max_value :: min_value :: numbers); 14 + [%expect 15 + {| 16 + ctz 0x7fff_ffff_ffff_ffff = 0 17 + ctz -0x8000_0000_0000_0000 = 63 18 + ctz 0x0 = 64 19 + ctz 0x1 = 0 20 + ctz 0x7 = 0 21 + ctz 0x2 = 1 22 + ctz 0x4 = 2 23 + ctz 0xc = 2 24 + ctz 0x12 = 1 25 + ctz -0x1 = 0 26 + |}] 27 + ;; 28 + 29 + let%expect_test "ctz int32" = 30 + let open Int32 in 31 + let numbers = List.map numbers ~f:of_int_trunc in 32 + let f = test ~op:I.Int32.count_trailing_zeros ~name:"ctz" (module Hex) (module Int32) in 33 + List.iter ~f (max_value :: min_value :: numbers); 34 + [%expect 35 + {| 36 + ctz 0x7fff_ffff = 0 37 + ctz -0x8000_0000 = 31 38 + ctz 0x0 = 32 39 + ctz 0x1 = 0 40 + ctz 0x7 = 0 41 + ctz 0x2 = 1 42 + ctz 0x4 = 2 43 + ctz 0xc = 2 44 + ctz 0x12 = 1 45 + ctz -0x1 = 0 46 + |}] 47 + ;; 48 + 49 + module%test [@tags "64-bits-only"] Arch64 = struct 50 + let%expect_test "ctz int" = 51 + let open Int in 52 + let f = 53 + test (module Int.Hex) (module Int) ~op:I.Int.count_trailing_zeros ~name:"ctz" 54 + in 55 + List.iter ~f (max_value :: min_value :: numbers); 56 + [%expect 57 + {| 58 + ctz 0x3fff_ffff_ffff_ffff = 0 59 + ctz -0x4000_0000_0000_0000 = 62 60 + ctz 0x0 = 63 61 + ctz 0x1 = 0 62 + ctz 0x7 = 0 63 + ctz 0x2 = 1 64 + ctz 0x4 = 2 65 + ctz 0xc = 2 66 + ctz 0x12 = 1 67 + ctz -0x1 = 0 68 + |}] 69 + ;; 70 + 71 + let%expect_test "ctz nativeint" = 72 + let open Nativeint in 73 + let numbers = List.map numbers ~f:of_int in 74 + let f = 75 + test 76 + (module Nativeint.Hex) 77 + (module Nativeint) 78 + ~op:I.Nativeint.count_trailing_zeros 79 + ~name:"ctz" 80 + in 81 + List.iter ~f (max_value :: min_value :: numbers); 82 + [%expect 83 + {| 84 + ctz 0x7fff_ffff_ffff_ffff = 0 85 + ctz -0x8000_0000_0000_0000 = 63 86 + ctz 0x0 = 64 87 + ctz 0x1 = 0 88 + ctz 0x7 = 0 89 + ctz 0x2 = 1 90 + ctz 0x4 = 2 91 + ctz 0xc = 2 92 + ctz 0x12 = 1 93 + ctz -0x1 = 0 94 + |}] 95 + ;; 96 + end 97 + 98 + module%test [@tags "32-bits-only", "js-only"] Arch32 = struct 99 + let%expect_test "ctz int" = 100 + let open Int in 101 + let f = 102 + test (module Int.Hex) (module Int) ~op:I.Int.count_trailing_zeros ~name:"ctz" 103 + in 104 + List.iter ~f (max_value :: min_value :: numbers); 105 + [%expect 106 + {| 107 + ctz 0x3fff_ffff = 0 108 + ctz -0x4000_0000 = 30 109 + ctz 0x0 = 31 110 + ctz 0x1 = 0 111 + ctz 0x7 = 0 112 + ctz 0x2 = 1 113 + ctz 0x4 = 2 114 + ctz 0xc = 2 115 + ctz 0x12 = 1 116 + ctz -0x1 = 0 117 + |}] 118 + ;; 119 + 120 + let%expect_test "ctz nativeint" = 121 + let open Nativeint in 122 + let numbers = List.map numbers ~f:of_int in 123 + let f = 124 + test 125 + (module Nativeint.Hex) 126 + (module Nativeint) 127 + ~op:I.Nativeint.count_trailing_zeros 128 + ~name:"ctz" 129 + in 130 + List.iter ~f (max_value :: min_value :: numbers); 131 + [%expect 132 + {| 133 + ctz 0x7fff_ffff = 0 134 + ctz -0x8000_0000 = 31 135 + ctz 0x0 = 32 136 + ctz 0x1 = 0 137 + ctz 0x7 = 0 138 + ctz 0x2 = 1 139 + ctz 0x4 = 2 140 + ctz 0xc = 2 141 + ctz 0x12 = 1 142 + ctz -0x1 = 0 143 + |}] 144 + ;; 145 + end
+1
vendor/opam/ocaml_intrinsics_kernel/test/test_ctz.mli
··· 1 + (*_ This signature is deliberately empty. *)
+79
vendor/opam/ocaml_intrinsics_kernel/test/test_float.ml
··· 1 + open! Base 2 + open! Stdio 3 + module I = Ocaml_intrinsics_kernel.Float 4 + 5 + let%expect_test "min and max" = 6 + let args = 7 + [ 0., 1. 8 + ; 1., 0. 9 + ; Float.neg_infinity, Float.infinity 10 + ; Float.infinity, Float.neg_infinity 11 + ; -0., 0. 12 + ; 0., -0. 13 + ; Float.nan, 0. 14 + ; 0., Float.nan 15 + ] 16 + in 17 + List.iter args ~f:(fun (x, y) -> printf "min %.19g %.19g = %.19g\n" x y (I.min x y)); 18 + [%expect 19 + {| 20 + min 0 1 = 0 21 + min 1 0 = 0 22 + min -inf inf = -inf 23 + min inf -inf = -inf 24 + min -0 0 = 0 25 + min 0 -0 = -0 26 + min nan 0 = 0 27 + min 0 nan = nan 28 + |}]; 29 + List.iter args ~f:(fun (x, y) -> printf "max %.19g %.19g = %.19g\n" x y (I.max x y)); 30 + [%expect 31 + {| 32 + max 0 1 = 1 33 + max 1 0 = 1 34 + max -inf inf = inf 35 + max inf -inf = inf 36 + max -0 0 = 0 37 + max 0 -0 = -0 38 + max nan 0 = 0 39 + max 0 nan = nan 40 + |}] 41 + ;; 42 + 43 + let%expect_test "iround" = 44 + let args = 45 + [ 0. 46 + ; -0. 47 + ; 0.4 48 + ; -0.4 49 + ; 0.6 50 + ; -0.6 51 + ; Float.of_int64 (Float.to_int64_preserve_order_exn Float.infinity) 52 + ; Float.of_int64 (Float.to_int64_preserve_order_exn Float.neg_infinity) 53 + ] 54 + in 55 + List.iter args ~f:(fun x -> printf "iround %.19g = %Ld\n" x (I.iround_current x)); 56 + [%expect 57 + {| 58 + iround 0 = 0 59 + iround -0 = 0 60 + iround 0.4000000000000000222 = 0 61 + iround -0.4000000000000000222 = 0 62 + iround 0.5999999999999999778 = 1 63 + iround -0.5999999999999999778 = -1 64 + iround 9218868437227405312 = 9218868437227405312 65 + iround -9218868437227405312 = -9218868437227405312 66 + |}] 67 + ;; 68 + 69 + let%expect_test ("iround half-to-even" [@tags "no-js"]) = 70 + let args = [ 0.5; -0.5; 1.5; -1.5 ] in 71 + List.iter args ~f:(fun x -> printf "iround %.19g = %Ld\n" x (I.iround_current x)); 72 + [%expect 73 + {| 74 + iround 0.5 = 0 75 + iround -0.5 = 0 76 + iround 1.5 = 2 77 + iround -1.5 = -2 78 + |}] 79 + ;;
+1
vendor/opam/ocaml_intrinsics_kernel/test/test_float.mli
··· 1 + (*_ This signature is deliberately empty. *)
+145
vendor/opam/ocaml_intrinsics_kernel/test/test_popcnt.ml
··· 1 + open Base 2 + open Import 3 + module I = Ocaml_intrinsics_kernel 4 + 5 + let%expect_test "popcnt int64" = 6 + let open Int64 in 7 + let numbers = [ 0L; 1L; 7L; max_value; min_value; -1L ] in 8 + let f = test ~op:I.Int64.count_set_bits ~name:"popcnt" (module Hex) (module Int64) in 9 + List.iter ~f numbers; 10 + [%expect 11 + {| 12 + popcnt 0x0 = 0 13 + popcnt 0x1 = 1 14 + popcnt 0x7 = 3 15 + popcnt 0x7fff_ffff_ffff_ffff = 63 16 + popcnt -0x8000_0000_0000_0000 = 1 17 + popcnt -0x1 = 64 18 + |}] 19 + ;; 20 + 21 + let%expect_test "popcnt int32" = 22 + let open Int32 in 23 + let numbers = [ 0l; 1l; 7l; max_value; min_value; -1l ] in 24 + let f = test ~op:I.Int32.count_set_bits ~name:"popcnt" (module Hex) (module Int32) in 25 + List.iter ~f numbers; 26 + [%expect 27 + {| 28 + popcnt 0x0 = 0 29 + popcnt 0x1 = 1 30 + popcnt 0x7 = 3 31 + popcnt 0x7fff_ffff = 31 32 + popcnt -0x8000_0000 = 1 33 + popcnt -0x1 = 32 34 + |}] 35 + ;; 36 + 37 + module%test [@tags "64-bits-only"] Arch64 = struct 38 + let%expect_test "popcnt int" = 39 + let open Int in 40 + let numbers = 41 + [ 0 42 + ; 1 43 + ; 7 44 + ; max_value (* Int.num_bits - 1 *) 45 + ; min_value (* 1 *) 46 + ; -1 (* Int.num_bits *) 47 + ] 48 + in 49 + let f = test (module Hex) (module Int) ~op:I.Int.count_set_bits ~name:"popcnt" in 50 + List.iter ~f numbers; 51 + [%expect 52 + {| 53 + popcnt 0x0 = 0 54 + popcnt 0x1 = 1 55 + popcnt 0x7 = 3 56 + popcnt 0x3fff_ffff_ffff_ffff = 62 57 + popcnt -0x4000_0000_0000_0000 = 1 58 + popcnt -0x1 = 63 59 + |}]; 60 + let f = test (module Hex) (module Int) ~op:I.Int.count_set_bits2 ~name:"popcnt2" in 61 + List.iter ~f numbers; 62 + [%expect 63 + {| 64 + popcnt2 0x0 = 0 65 + popcnt2 0x1 = 1 66 + popcnt2 0x7 = 3 67 + popcnt2 0x3fff_ffff_ffff_ffff = 62 68 + popcnt2 -0x4000_0000_0000_0000 = 1 69 + popcnt2 -0x1 = 63 70 + |}] 71 + ;; 72 + 73 + let%expect_test "popcnt nativeint" = 74 + let open Nativeint in 75 + let numbers = [ 0n; 1n; 7n; max_value; min_value; -1n ] in 76 + let f = 77 + test (module Hex) (module Nativeint) ~op:I.Nativeint.count_set_bits ~name:"popcnt" 78 + in 79 + List.iter ~f numbers; 80 + [%expect 81 + {| 82 + popcnt 0x0 = 0 83 + popcnt 0x1 = 1 84 + popcnt 0x7 = 3 85 + popcnt 0x7fff_ffff_ffff_ffff = 63 86 + popcnt -0x8000_0000_0000_0000 = 1 87 + popcnt -0x1 = 64 88 + |}] 89 + ;; 90 + end 91 + 92 + module%test [@tags "32-bits-only", "js-only"] Arch32 = struct 93 + let%expect_test "popcnt int" = 94 + let open Int in 95 + let numbers = 96 + [ 0 97 + ; 1 98 + ; 7 99 + ; max_value (* Int.num_bits - 1 *) 100 + ; min_value (* 1 *) 101 + ; -1 (* Int.num_bits *) 102 + ] 103 + in 104 + let f = test (module Hex) (module Int) ~op:I.Int.count_set_bits ~name:"popcnt" in 105 + List.iter ~f numbers; 106 + [%expect 107 + {| 108 + popcnt 0x0 = 0 109 + popcnt 0x1 = 1 110 + popcnt 0x7 = 3 111 + popcnt 0x3fff_ffff = 30 112 + popcnt -0x4000_0000 = 1 113 + popcnt -0x1 = 31 114 + |}]; 115 + let f = test (module Hex) (module Int) ~op:I.Int.count_set_bits2 ~name:"popcnt2" in 116 + List.iter ~f numbers; 117 + [%expect 118 + {| 119 + popcnt2 0x0 = 0 120 + popcnt2 0x1 = 1 121 + popcnt2 0x7 = 3 122 + popcnt2 0x3fff_ffff = 30 123 + popcnt2 -0x4000_0000 = 1 124 + popcnt2 -0x1 = 31 125 + |}] 126 + ;; 127 + 128 + let%expect_test "popcnt nativeint" = 129 + let open Nativeint in 130 + let numbers = [ 0n; 1n; 7n; max_value; min_value; -1n ] in 131 + let f = 132 + test (module Hex) (module Nativeint) ~op:I.Nativeint.count_set_bits ~name:"popcnt" 133 + in 134 + List.iter ~f numbers; 135 + [%expect 136 + {| 137 + popcnt 0x0 = 0 138 + popcnt 0x1 = 1 139 + popcnt 0x7 = 3 140 + popcnt 0x7fff_ffff = 31 141 + popcnt -0x8000_0000 = 1 142 + popcnt -0x1 = 32 143 + |}] 144 + ;; 145 + end
+1
vendor/opam/ocaml_intrinsics_kernel/test/test_popcnt.mli
··· 1 + (*_ This signature is deliberately empty. *)
+2644
vendor/opam/ocaml_intrinsics_kernel/test/test_shifts.ml
··· 1 + open Base 2 + open Import 3 + module I = Ocaml_intrinsics_kernel 4 + 5 + let numbers = [ 0; 1; 5; 7; -1; -3 ] 6 + let shifts = [ 0; 1; 2; 3; 4; 31; 32; 33; 62; 63; 64; 65; 66; -1; -3 ] 7 + 8 + module%test Int64 = struct 9 + open Int64 10 + 11 + let numbers = List.map ~f:of_int numbers @ [ max_value; min_value ] 12 + let shifts = List.map ~f:of_int shifts @ [ max_value; min_value ] 13 + 14 + let test ~op ~expected_op ~name = 15 + let f ~shift x = 16 + test_shifts (module Int64.Binary) (module Int64) ~op ~expected_op ~name x shift 17 + in 18 + List.iter shifts ~f:(fun shift -> 19 + let f = f ~shift in 20 + List.iter ~f numbers) 21 + ;; 22 + 23 + let%expect_test "shift_left int64" = 24 + test 25 + ~op:I.Int64.shift_left 26 + ~expected_op:I.Int64.Naive.shift_left 27 + ~name:"Int64.shift_left"; 28 + [%expect 29 + {| 30 + 0b0 Int64.shift_left by 0 = 31 + 0b0 32 + 0b1 Int64.shift_left by 0 = 33 + 0b1 34 + 0b101 Int64.shift_left by 0 = 35 + 0b101 36 + 0b111 Int64.shift_left by 0 = 37 + 0b111 38 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_left by 0 = 39 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 40 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_left by 0 = 41 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 42 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_left by 0 = 43 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 44 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_left by 0 = 45 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 46 + 0b0 Int64.shift_left by 1 = 47 + 0b0 48 + 0b1 Int64.shift_left by 1 = 49 + 0b10 50 + 0b101 Int64.shift_left by 1 = 51 + 0b1010 52 + 0b111 Int64.shift_left by 1 = 53 + 0b1110 54 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_left by 1 = 55 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1110 56 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_left by 1 = 57 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1010 58 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_left by 1 = 59 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1110 60 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_left by 1 = 61 + 0b0 62 + 0b0 Int64.shift_left by 2 = 63 + 0b0 64 + 0b1 Int64.shift_left by 2 = 65 + 0b100 66 + 0b101 Int64.shift_left by 2 = 67 + 0b1_0100 68 + 0b111 Int64.shift_left by 2 = 69 + 0b1_1100 70 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_left by 2 = 71 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1100 72 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_left by 2 = 73 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_0100 74 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_left by 2 = 75 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1100 76 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_left by 2 = 77 + 0b0 78 + 0b0 Int64.shift_left by 3 = 79 + 0b0 80 + 0b1 Int64.shift_left by 3 = 81 + 0b1000 82 + 0b101 Int64.shift_left by 3 = 83 + 0b10_1000 84 + 0b111 Int64.shift_left by 3 = 85 + 0b11_1000 86 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_left by 3 = 87 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1000 88 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_left by 3 = 89 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1110_1000 90 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_left by 3 = 91 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1000 92 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_left by 3 = 93 + 0b0 94 + 0b0 Int64.shift_left by 4 = 95 + 0b0 96 + 0b1 Int64.shift_left by 4 = 97 + 0b1_0000 98 + 0b101 Int64.shift_left by 4 = 99 + 0b101_0000 100 + 0b111 Int64.shift_left by 4 = 101 + 0b111_0000 102 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_left by 4 = 103 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_0000 104 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_left by 4 = 105 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101_0000 106 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_left by 4 = 107 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_0000 108 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_left by 4 = 109 + 0b0 110 + 0b0 Int64.shift_left by 31 = 111 + 0b0 112 + 0b1 Int64.shift_left by 31 = 113 + 0b1000_0000_0000_0000_0000_0000_0000_0000 114 + 0b101 Int64.shift_left by 31 = 115 + 0b10_1000_0000_0000_0000_0000_0000_0000_0000 116 + 0b111 Int64.shift_left by 31 = 117 + 0b11_1000_0000_0000_0000_0000_0000_0000_0000 118 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_left by 31 = 119 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1000_0000_0000_0000_0000_0000_0000_0000 120 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_left by 31 = 121 + 0b1111_1111_1111_1111_1111_1111_1111_1110_1000_0000_0000_0000_0000_0000_0000_0000 122 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_left by 31 = 123 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1000_0000_0000_0000_0000_0000_0000_0000 124 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_left by 31 = 125 + 0b0 126 + 0b0 Int64.shift_left by 32 = 127 + 0b0 128 + 0b1 Int64.shift_left by 32 = 129 + 0b1_0000_0000_0000_0000_0000_0000_0000_0000 130 + 0b101 Int64.shift_left by 32 = 131 + 0b101_0000_0000_0000_0000_0000_0000_0000_0000 132 + 0b111 Int64.shift_left by 32 = 133 + 0b111_0000_0000_0000_0000_0000_0000_0000_0000 134 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_left by 32 = 135 + 0b1111_1111_1111_1111_1111_1111_1111_1111_0000_0000_0000_0000_0000_0000_0000_0000 136 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_left by 32 = 137 + 0b1111_1111_1111_1111_1111_1111_1111_1101_0000_0000_0000_0000_0000_0000_0000_0000 138 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_left by 32 = 139 + 0b1111_1111_1111_1111_1111_1111_1111_1111_0000_0000_0000_0000_0000_0000_0000_0000 140 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_left by 32 = 141 + 0b0 142 + 0b0 Int64.shift_left by 33 = 143 + 0b0 144 + 0b1 Int64.shift_left by 33 = 145 + 0b10_0000_0000_0000_0000_0000_0000_0000_0000 146 + 0b101 Int64.shift_left by 33 = 147 + 0b1010_0000_0000_0000_0000_0000_0000_0000_0000 148 + 0b111 Int64.shift_left by 33 = 149 + 0b1110_0000_0000_0000_0000_0000_0000_0000_0000 150 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_left by 33 = 151 + 0b1111_1111_1111_1111_1111_1111_1111_1110_0000_0000_0000_0000_0000_0000_0000_0000 152 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_left by 33 = 153 + 0b1111_1111_1111_1111_1111_1111_1111_1010_0000_0000_0000_0000_0000_0000_0000_0000 154 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_left by 33 = 155 + 0b1111_1111_1111_1111_1111_1111_1111_1110_0000_0000_0000_0000_0000_0000_0000_0000 156 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_left by 33 = 157 + 0b0 158 + 0b0 Int64.shift_left by 62 = 159 + 0b0 160 + 0b1 Int64.shift_left by 62 = 161 + 0b100_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 162 + 0b101 Int64.shift_left by 62 = 163 + 0b100_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 164 + 0b111 Int64.shift_left by 62 = 165 + 0b1100_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 166 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_left by 62 = 167 + 0b1100_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 168 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_left by 62 = 169 + 0b100_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 170 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_left by 62 = 171 + 0b1100_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 172 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_left by 62 = 173 + 0b0 174 + 0b0 Int64.shift_left by 63 = 175 + 0b0 176 + 0b1 Int64.shift_left by 63 = 177 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 178 + 0b101 Int64.shift_left by 63 = 179 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 180 + 0b111 Int64.shift_left by 63 = 181 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 182 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_left by 63 = 183 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 184 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_left by 63 = 185 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 186 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_left by 63 = 187 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 188 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_left by 63 = 189 + 0b0 190 + 0b0 Int64.shift_left by 64 = 191 + 0b0 192 + 0b1 Int64.shift_left by 64 = 193 + 0b1 194 + 0b101 Int64.shift_left by 64 = 195 + 0b101 196 + 0b111 Int64.shift_left by 64 = 197 + 0b111 198 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_left by 64 = 199 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 200 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_left by 64 = 201 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 202 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_left by 64 = 203 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 204 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_left by 64 = 205 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 206 + 0b0 Int64.shift_left by 65 = 207 + 0b0 208 + 0b1 Int64.shift_left by 65 = 209 + 0b10 210 + 0b101 Int64.shift_left by 65 = 211 + 0b1010 212 + 0b111 Int64.shift_left by 65 = 213 + 0b1110 214 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_left by 65 = 215 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1110 216 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_left by 65 = 217 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1010 218 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_left by 65 = 219 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1110 220 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_left by 65 = 221 + 0b0 222 + 0b0 Int64.shift_left by 66 = 223 + 0b0 224 + 0b1 Int64.shift_left by 66 = 225 + 0b100 226 + 0b101 Int64.shift_left by 66 = 227 + 0b1_0100 228 + 0b111 Int64.shift_left by 66 = 229 + 0b1_1100 230 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_left by 66 = 231 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1100 232 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_left by 66 = 233 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_0100 234 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_left by 66 = 235 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1100 236 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_left by 66 = 237 + 0b0 238 + 0b0 Int64.shift_left by -1 = 239 + 0b0 240 + 0b1 Int64.shift_left by -1 = 241 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 242 + 0b101 Int64.shift_left by -1 = 243 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 244 + 0b111 Int64.shift_left by -1 = 245 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 246 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_left by -1 = 247 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 248 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_left by -1 = 249 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 250 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_left by -1 = 251 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 252 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_left by -1 = 253 + 0b0 254 + 0b0 Int64.shift_left by -3 = 255 + 0b0 256 + 0b1 Int64.shift_left by -3 = 257 + 0b10_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 258 + 0b101 Int64.shift_left by -3 = 259 + 0b1010_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 260 + 0b111 Int64.shift_left by -3 = 261 + 0b1110_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 262 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_left by -3 = 263 + 0b1110_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 264 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_left by -3 = 265 + 0b1010_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 266 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_left by -3 = 267 + 0b1110_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 268 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_left by -3 = 269 + 0b0 270 + 0b0 Int64.shift_left by 9_223_372_036_854_775_807 = 271 + 0b0 272 + 0b1 Int64.shift_left by 9_223_372_036_854_775_807 = 273 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 274 + 0b101 Int64.shift_left by 9_223_372_036_854_775_807 = 275 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 276 + 0b111 Int64.shift_left by 9_223_372_036_854_775_807 = 277 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 278 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_left by 9_223_372_036_854_775_807 = 279 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 280 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_left by 9_223_372_036_854_775_807 = 281 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 282 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_left by 9_223_372_036_854_775_807 = 283 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 284 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_left by 9_223_372_036_854_775_807 = 285 + 0b0 286 + 0b0 Int64.shift_left by -9_223_372_036_854_775_808 = 287 + 0b0 288 + 0b1 Int64.shift_left by -9_223_372_036_854_775_808 = 289 + 0b1 290 + 0b101 Int64.shift_left by -9_223_372_036_854_775_808 = 291 + 0b101 292 + 0b111 Int64.shift_left by -9_223_372_036_854_775_808 = 293 + 0b111 294 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_left by -9_223_372_036_854_775_808 = 295 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 296 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_left by -9_223_372_036_854_775_808 = 297 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 298 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_left by -9_223_372_036_854_775_808 = 299 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 300 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_left by -9_223_372_036_854_775_808 = 301 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 302 + |}]; 303 + () 304 + ;; 305 + 306 + let%expect_test "shift_right int64" = 307 + test 308 + ~op:I.Int64.shift_right 309 + ~expected_op:I.Int64.Naive.shift_right 310 + ~name:"Int64.shift_right"; 311 + [%expect 312 + {| 313 + 0b0 Int64.shift_right by 0 = 314 + 0b0 315 + 0b1 Int64.shift_right by 0 = 316 + 0b1 317 + 0b101 Int64.shift_right by 0 = 318 + 0b101 319 + 0b111 Int64.shift_right by 0 = 320 + 0b111 321 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right by 0 = 322 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 323 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_right by 0 = 324 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 325 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right by 0 = 326 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 327 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_right by 0 = 328 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 329 + 0b0 Int64.shift_right by 1 = 330 + 0b0 331 + 0b1 Int64.shift_right by 1 = 332 + 0b0 333 + 0b101 Int64.shift_right by 1 = 334 + 0b10 335 + 0b111 Int64.shift_right by 1 = 336 + 0b11 337 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right by 1 = 338 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 339 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_right by 1 = 340 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1110 341 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right by 1 = 342 + 0b11_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 343 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_right by 1 = 344 + 0b1100_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 345 + 0b0 Int64.shift_right by 2 = 346 + 0b0 347 + 0b1 Int64.shift_right by 2 = 348 + 0b0 349 + 0b101 Int64.shift_right by 2 = 350 + 0b1 351 + 0b111 Int64.shift_right by 2 = 352 + 0b1 353 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right by 2 = 354 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 355 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_right by 2 = 356 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 357 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right by 2 = 358 + 0b1_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 359 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_right by 2 = 360 + 0b1110_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 361 + 0b0 Int64.shift_right by 3 = 362 + 0b0 363 + 0b1 Int64.shift_right by 3 = 364 + 0b0 365 + 0b101 Int64.shift_right by 3 = 366 + 0b0 367 + 0b111 Int64.shift_right by 3 = 368 + 0b0 369 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right by 3 = 370 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 371 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_right by 3 = 372 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 373 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right by 3 = 374 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 375 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_right by 3 = 376 + 0b1111_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 377 + 0b0 Int64.shift_right by 4 = 378 + 0b0 379 + 0b1 Int64.shift_right by 4 = 380 + 0b0 381 + 0b101 Int64.shift_right by 4 = 382 + 0b0 383 + 0b111 Int64.shift_right by 4 = 384 + 0b0 385 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right by 4 = 386 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 387 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_right by 4 = 388 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 389 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right by 4 = 390 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 391 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_right by 4 = 392 + 0b1111_1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 393 + 0b0 Int64.shift_right by 31 = 394 + 0b0 395 + 0b1 Int64.shift_right by 31 = 396 + 0b0 397 + 0b101 Int64.shift_right by 31 = 398 + 0b0 399 + 0b111 Int64.shift_right by 31 = 400 + 0b0 401 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right by 31 = 402 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 403 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_right by 31 = 404 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 405 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right by 31 = 406 + 0b1111_1111_1111_1111_1111_1111_1111_1111 407 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_right by 31 = 408 + 0b1111_1111_1111_1111_1111_1111_1111_1111_0000_0000_0000_0000_0000_0000_0000_0000 409 + 0b0 Int64.shift_right by 32 = 410 + 0b0 411 + 0b1 Int64.shift_right by 32 = 412 + 0b0 413 + 0b101 Int64.shift_right by 32 = 414 + 0b0 415 + 0b111 Int64.shift_right by 32 = 416 + 0b0 417 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right by 32 = 418 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 419 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_right by 32 = 420 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 421 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right by 32 = 422 + 0b111_1111_1111_1111_1111_1111_1111_1111 423 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_right by 32 = 424 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1000_0000_0000_0000_0000_0000_0000_0000 425 + 0b0 Int64.shift_right by 33 = 426 + 0b0 427 + 0b1 Int64.shift_right by 33 = 428 + 0b0 429 + 0b101 Int64.shift_right by 33 = 430 + 0b0 431 + 0b111 Int64.shift_right by 33 = 432 + 0b0 433 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right by 33 = 434 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 435 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_right by 33 = 436 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 437 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right by 33 = 438 + 0b11_1111_1111_1111_1111_1111_1111_1111 439 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_right by 33 = 440 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1100_0000_0000_0000_0000_0000_0000_0000 441 + 0b0 Int64.shift_right by 62 = 442 + 0b0 443 + 0b1 Int64.shift_right by 62 = 444 + 0b0 445 + 0b101 Int64.shift_right by 62 = 446 + 0b0 447 + 0b111 Int64.shift_right by 62 = 448 + 0b0 449 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right by 62 = 450 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 451 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_right by 62 = 452 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 453 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right by 62 = 454 + 0b1 455 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_right by 62 = 456 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1110 457 + 0b0 Int64.shift_right by 63 = 458 + 0b0 459 + 0b1 Int64.shift_right by 63 = 460 + 0b0 461 + 0b101 Int64.shift_right by 63 = 462 + 0b0 463 + 0b111 Int64.shift_right by 63 = 464 + 0b0 465 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right by 63 = 466 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 467 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_right by 63 = 468 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 469 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right by 63 = 470 + 0b0 471 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_right by 63 = 472 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 473 + 0b0 Int64.shift_right by 64 = 474 + 0b0 475 + 0b1 Int64.shift_right by 64 = 476 + 0b1 477 + 0b101 Int64.shift_right by 64 = 478 + 0b101 479 + 0b111 Int64.shift_right by 64 = 480 + 0b111 481 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right by 64 = 482 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 483 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_right by 64 = 484 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 485 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right by 64 = 486 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 487 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_right by 64 = 488 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 489 + 0b0 Int64.shift_right by 65 = 490 + 0b0 491 + 0b1 Int64.shift_right by 65 = 492 + 0b0 493 + 0b101 Int64.shift_right by 65 = 494 + 0b10 495 + 0b111 Int64.shift_right by 65 = 496 + 0b11 497 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right by 65 = 498 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 499 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_right by 65 = 500 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1110 501 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right by 65 = 502 + 0b11_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 503 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_right by 65 = 504 + 0b1100_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 505 + 0b0 Int64.shift_right by 66 = 506 + 0b0 507 + 0b1 Int64.shift_right by 66 = 508 + 0b0 509 + 0b101 Int64.shift_right by 66 = 510 + 0b1 511 + 0b111 Int64.shift_right by 66 = 512 + 0b1 513 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right by 66 = 514 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 515 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_right by 66 = 516 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 517 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right by 66 = 518 + 0b1_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 519 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_right by 66 = 520 + 0b1110_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 521 + 0b0 Int64.shift_right by -1 = 522 + 0b0 523 + 0b1 Int64.shift_right by -1 = 524 + 0b0 525 + 0b101 Int64.shift_right by -1 = 526 + 0b0 527 + 0b111 Int64.shift_right by -1 = 528 + 0b0 529 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right by -1 = 530 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 531 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_right by -1 = 532 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 533 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right by -1 = 534 + 0b0 535 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_right by -1 = 536 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 537 + 0b0 Int64.shift_right by -3 = 538 + 0b0 539 + 0b1 Int64.shift_right by -3 = 540 + 0b0 541 + 0b101 Int64.shift_right by -3 = 542 + 0b0 543 + 0b111 Int64.shift_right by -3 = 544 + 0b0 545 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right by -3 = 546 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 547 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_right by -3 = 548 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 549 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right by -3 = 550 + 0b11 551 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_right by -3 = 552 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1100 553 + 0b0 Int64.shift_right by 9_223_372_036_854_775_807 = 554 + 0b0 555 + 0b1 Int64.shift_right by 9_223_372_036_854_775_807 = 556 + 0b0 557 + 0b101 Int64.shift_right by 9_223_372_036_854_775_807 = 558 + 0b0 559 + 0b111 Int64.shift_right by 9_223_372_036_854_775_807 = 560 + 0b0 561 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right by 9_223_372_036_854_775_807 = 562 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 563 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_right by 9_223_372_036_854_775_807 = 564 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 565 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right by 9_223_372_036_854_775_807 = 566 + 0b0 567 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_right by 9_223_372_036_854_775_807 = 568 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 569 + 0b0 Int64.shift_right by -9_223_372_036_854_775_808 = 570 + 0b0 571 + 0b1 Int64.shift_right by -9_223_372_036_854_775_808 = 572 + 0b1 573 + 0b101 Int64.shift_right by -9_223_372_036_854_775_808 = 574 + 0b101 575 + 0b111 Int64.shift_right by -9_223_372_036_854_775_808 = 576 + 0b111 577 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right by -9_223_372_036_854_775_808 = 578 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 579 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_right by -9_223_372_036_854_775_808 = 580 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 581 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right by -9_223_372_036_854_775_808 = 582 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 583 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_right by -9_223_372_036_854_775_808 = 584 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 585 + |}]; 586 + () 587 + ;; 588 + 589 + let%expect_test "shift_right_logical int64" = 590 + test 591 + ~op:I.Int64.shift_right_logical 592 + ~expected_op:I.Int64.Naive.shift_right_logical 593 + ~name:"Int64.shift_right_logical"; 594 + [%expect 595 + {| 596 + 0b0 Int64.shift_right_logical by 0 = 597 + 0b0 598 + 0b1 Int64.shift_right_logical by 0 = 599 + 0b1 600 + 0b101 Int64.shift_right_logical by 0 = 601 + 0b101 602 + 0b111 Int64.shift_right_logical by 0 = 603 + 0b111 604 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right_logical by 0 = 605 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 606 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_right_logical by 0 = 607 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 608 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right_logical by 0 = 609 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 610 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_right_logical by 0 = 611 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 612 + 0b0 Int64.shift_right_logical by 1 = 613 + 0b0 614 + 0b1 Int64.shift_right_logical by 1 = 615 + 0b0 616 + 0b101 Int64.shift_right_logical by 1 = 617 + 0b10 618 + 0b111 Int64.shift_right_logical by 1 = 619 + 0b11 620 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right_logical by 1 = 621 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 622 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_right_logical by 1 = 623 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1110 624 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right_logical by 1 = 625 + 0b11_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 626 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_right_logical by 1 = 627 + 0b100_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 628 + 0b0 Int64.shift_right_logical by 2 = 629 + 0b0 630 + 0b1 Int64.shift_right_logical by 2 = 631 + 0b0 632 + 0b101 Int64.shift_right_logical by 2 = 633 + 0b1 634 + 0b111 Int64.shift_right_logical by 2 = 635 + 0b1 636 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right_logical by 2 = 637 + 0b11_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 638 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_right_logical by 2 = 639 + 0b11_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 640 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right_logical by 2 = 641 + 0b1_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 642 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_right_logical by 2 = 643 + 0b10_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 644 + 0b0 Int64.shift_right_logical by 3 = 645 + 0b0 646 + 0b1 Int64.shift_right_logical by 3 = 647 + 0b0 648 + 0b101 Int64.shift_right_logical by 3 = 649 + 0b0 650 + 0b111 Int64.shift_right_logical by 3 = 651 + 0b0 652 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right_logical by 3 = 653 + 0b1_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 654 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_right_logical by 3 = 655 + 0b1_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 656 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right_logical by 3 = 657 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 658 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_right_logical by 3 = 659 + 0b1_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 660 + 0b0 Int64.shift_right_logical by 4 = 661 + 0b0 662 + 0b1 Int64.shift_right_logical by 4 = 663 + 0b0 664 + 0b101 Int64.shift_right_logical by 4 = 665 + 0b0 666 + 0b111 Int64.shift_right_logical by 4 = 667 + 0b0 668 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right_logical by 4 = 669 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 670 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_right_logical by 4 = 671 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 672 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right_logical by 4 = 673 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 674 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_right_logical by 4 = 675 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 676 + 0b0 Int64.shift_right_logical by 31 = 677 + 0b0 678 + 0b1 Int64.shift_right_logical by 31 = 679 + 0b0 680 + 0b101 Int64.shift_right_logical by 31 = 681 + 0b0 682 + 0b111 Int64.shift_right_logical by 31 = 683 + 0b0 684 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right_logical by 31 = 685 + 0b1_1111_1111_1111_1111_1111_1111_1111_1111 686 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_right_logical by 31 = 687 + 0b1_1111_1111_1111_1111_1111_1111_1111_1111 688 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right_logical by 31 = 689 + 0b1111_1111_1111_1111_1111_1111_1111_1111 690 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_right_logical by 31 = 691 + 0b1_0000_0000_0000_0000_0000_0000_0000_0000 692 + 0b0 Int64.shift_right_logical by 32 = 693 + 0b0 694 + 0b1 Int64.shift_right_logical by 32 = 695 + 0b0 696 + 0b101 Int64.shift_right_logical by 32 = 697 + 0b0 698 + 0b111 Int64.shift_right_logical by 32 = 699 + 0b0 700 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right_logical by 32 = 701 + 0b1111_1111_1111_1111_1111_1111_1111_1111 702 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_right_logical by 32 = 703 + 0b1111_1111_1111_1111_1111_1111_1111_1111 704 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right_logical by 32 = 705 + 0b111_1111_1111_1111_1111_1111_1111_1111 706 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_right_logical by 32 = 707 + 0b1000_0000_0000_0000_0000_0000_0000_0000 708 + 0b0 Int64.shift_right_logical by 33 = 709 + 0b0 710 + 0b1 Int64.shift_right_logical by 33 = 711 + 0b0 712 + 0b101 Int64.shift_right_logical by 33 = 713 + 0b0 714 + 0b111 Int64.shift_right_logical by 33 = 715 + 0b0 716 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right_logical by 33 = 717 + 0b111_1111_1111_1111_1111_1111_1111_1111 718 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_right_logical by 33 = 719 + 0b111_1111_1111_1111_1111_1111_1111_1111 720 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right_logical by 33 = 721 + 0b11_1111_1111_1111_1111_1111_1111_1111 722 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_right_logical by 33 = 723 + 0b100_0000_0000_0000_0000_0000_0000_0000 724 + 0b0 Int64.shift_right_logical by 62 = 725 + 0b0 726 + 0b1 Int64.shift_right_logical by 62 = 727 + 0b0 728 + 0b101 Int64.shift_right_logical by 62 = 729 + 0b0 730 + 0b111 Int64.shift_right_logical by 62 = 731 + 0b0 732 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right_logical by 62 = 733 + 0b11 734 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_right_logical by 62 = 735 + 0b11 736 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right_logical by 62 = 737 + 0b1 738 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_right_logical by 62 = 739 + 0b10 740 + 0b0 Int64.shift_right_logical by 63 = 741 + 0b0 742 + 0b1 Int64.shift_right_logical by 63 = 743 + 0b0 744 + 0b101 Int64.shift_right_logical by 63 = 745 + 0b0 746 + 0b111 Int64.shift_right_logical by 63 = 747 + 0b0 748 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right_logical by 63 = 749 + 0b1 750 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_right_logical by 63 = 751 + 0b1 752 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right_logical by 63 = 753 + 0b0 754 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_right_logical by 63 = 755 + 0b1 756 + 0b0 Int64.shift_right_logical by 64 = 757 + 0b0 758 + 0b1 Int64.shift_right_logical by 64 = 759 + 0b1 760 + 0b101 Int64.shift_right_logical by 64 = 761 + 0b101 762 + 0b111 Int64.shift_right_logical by 64 = 763 + 0b111 764 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right_logical by 64 = 765 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 766 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_right_logical by 64 = 767 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 768 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right_logical by 64 = 769 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 770 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_right_logical by 64 = 771 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 772 + 0b0 Int64.shift_right_logical by 65 = 773 + 0b0 774 + 0b1 Int64.shift_right_logical by 65 = 775 + 0b0 776 + 0b101 Int64.shift_right_logical by 65 = 777 + 0b10 778 + 0b111 Int64.shift_right_logical by 65 = 779 + 0b11 780 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right_logical by 65 = 781 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 782 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_right_logical by 65 = 783 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1110 784 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right_logical by 65 = 785 + 0b11_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 786 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_right_logical by 65 = 787 + 0b100_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 788 + 0b0 Int64.shift_right_logical by 66 = 789 + 0b0 790 + 0b1 Int64.shift_right_logical by 66 = 791 + 0b0 792 + 0b101 Int64.shift_right_logical by 66 = 793 + 0b1 794 + 0b111 Int64.shift_right_logical by 66 = 795 + 0b1 796 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right_logical by 66 = 797 + 0b11_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 798 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_right_logical by 66 = 799 + 0b11_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 800 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right_logical by 66 = 801 + 0b1_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 802 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_right_logical by 66 = 803 + 0b10_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 804 + 0b0 Int64.shift_right_logical by -1 = 805 + 0b0 806 + 0b1 Int64.shift_right_logical by -1 = 807 + 0b0 808 + 0b101 Int64.shift_right_logical by -1 = 809 + 0b0 810 + 0b111 Int64.shift_right_logical by -1 = 811 + 0b0 812 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right_logical by -1 = 813 + 0b1 814 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_right_logical by -1 = 815 + 0b1 816 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right_logical by -1 = 817 + 0b0 818 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_right_logical by -1 = 819 + 0b1 820 + 0b0 Int64.shift_right_logical by -3 = 821 + 0b0 822 + 0b1 Int64.shift_right_logical by -3 = 823 + 0b0 824 + 0b101 Int64.shift_right_logical by -3 = 825 + 0b0 826 + 0b111 Int64.shift_right_logical by -3 = 827 + 0b0 828 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right_logical by -3 = 829 + 0b111 830 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_right_logical by -3 = 831 + 0b111 832 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right_logical by -3 = 833 + 0b11 834 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_right_logical by -3 = 835 + 0b100 836 + 0b0 Int64.shift_right_logical by 9_223_372_036_854_775_807 = 837 + 0b0 838 + 0b1 Int64.shift_right_logical by 9_223_372_036_854_775_807 = 839 + 0b0 840 + 0b101 Int64.shift_right_logical by 9_223_372_036_854_775_807 = 841 + 0b0 842 + 0b111 Int64.shift_right_logical by 9_223_372_036_854_775_807 = 843 + 0b0 844 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right_logical by 9_223_372_036_854_775_807 = 845 + 0b1 846 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_right_logical by 9_223_372_036_854_775_807 = 847 + 0b1 848 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right_logical by 9_223_372_036_854_775_807 = 849 + 0b0 850 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_right_logical by 9_223_372_036_854_775_807 = 851 + 0b1 852 + 0b0 Int64.shift_right_logical by -9_223_372_036_854_775_808 = 853 + 0b0 854 + 0b1 Int64.shift_right_logical by -9_223_372_036_854_775_808 = 855 + 0b1 856 + 0b101 Int64.shift_right_logical by -9_223_372_036_854_775_808 = 857 + 0b101 858 + 0b111 Int64.shift_right_logical by -9_223_372_036_854_775_808 = 859 + 0b111 860 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right_logical by -9_223_372_036_854_775_808 = 861 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 862 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Int64.shift_right_logical by -9_223_372_036_854_775_808 = 863 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 864 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Int64.shift_right_logical by -9_223_372_036_854_775_808 = 865 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 866 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Int64.shift_right_logical by -9_223_372_036_854_775_808 = 867 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 868 + |}]; 869 + () 870 + ;; 871 + end 872 + 873 + module%test Int32 = struct 874 + open Int32 875 + 876 + let numbers = List.map ~f:of_int_exn numbers @ [ max_value; min_value ] 877 + let shifts = List.map ~f:of_int_exn shifts @ [ max_value; min_value ] 878 + 879 + let test ~op ~expected_op ~name = 880 + let f ~shift x = 881 + test_shifts (module Binary) (module Int32) ~op ~expected_op ~name x shift 882 + in 883 + List.iter shifts ~f:(fun shift -> 884 + let f = f ~shift in 885 + List.iter ~f numbers) 886 + ;; 887 + 888 + let%expect_test "shift_left int32" = 889 + test 890 + ~op:I.Int32.shift_left 891 + ~expected_op:I.Int32.Naive.shift_left 892 + ~name:"Int32.shift_left"; 893 + [%expect 894 + {| 895 + 0b0 Int32.shift_left by 0 = 896 + 0b0 897 + 0b1 Int32.shift_left by 0 = 898 + 0b1 899 + 0b101 Int32.shift_left by 0 = 900 + 0b101 901 + 0b111 Int32.shift_left by 0 = 902 + 0b111 903 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_left by 0 = 904 + 0b1111_1111_1111_1111_1111_1111_1111_1111 905 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_left by 0 = 906 + 0b1111_1111_1111_1111_1111_1111_1111_1101 907 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_left by 0 = 908 + 0b111_1111_1111_1111_1111_1111_1111_1111 909 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_left by 0 = 910 + 0b1000_0000_0000_0000_0000_0000_0000_0000 911 + 0b0 Int32.shift_left by 1 = 912 + 0b0 913 + 0b1 Int32.shift_left by 1 = 914 + 0b10 915 + 0b101 Int32.shift_left by 1 = 916 + 0b1010 917 + 0b111 Int32.shift_left by 1 = 918 + 0b1110 919 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_left by 1 = 920 + 0b1111_1111_1111_1111_1111_1111_1111_1110 921 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_left by 1 = 922 + 0b1111_1111_1111_1111_1111_1111_1111_1010 923 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_left by 1 = 924 + 0b1111_1111_1111_1111_1111_1111_1111_1110 925 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_left by 1 = 926 + 0b0 927 + 0b0 Int32.shift_left by 2 = 928 + 0b0 929 + 0b1 Int32.shift_left by 2 = 930 + 0b100 931 + 0b101 Int32.shift_left by 2 = 932 + 0b1_0100 933 + 0b111 Int32.shift_left by 2 = 934 + 0b1_1100 935 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_left by 2 = 936 + 0b1111_1111_1111_1111_1111_1111_1111_1100 937 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_left by 2 = 938 + 0b1111_1111_1111_1111_1111_1111_1111_0100 939 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_left by 2 = 940 + 0b1111_1111_1111_1111_1111_1111_1111_1100 941 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_left by 2 = 942 + 0b0 943 + 0b0 Int32.shift_left by 3 = 944 + 0b0 945 + 0b1 Int32.shift_left by 3 = 946 + 0b1000 947 + 0b101 Int32.shift_left by 3 = 948 + 0b10_1000 949 + 0b111 Int32.shift_left by 3 = 950 + 0b11_1000 951 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_left by 3 = 952 + 0b1111_1111_1111_1111_1111_1111_1111_1000 953 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_left by 3 = 954 + 0b1111_1111_1111_1111_1111_1111_1110_1000 955 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_left by 3 = 956 + 0b1111_1111_1111_1111_1111_1111_1111_1000 957 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_left by 3 = 958 + 0b0 959 + 0b0 Int32.shift_left by 4 = 960 + 0b0 961 + 0b1 Int32.shift_left by 4 = 962 + 0b1_0000 963 + 0b101 Int32.shift_left by 4 = 964 + 0b101_0000 965 + 0b111 Int32.shift_left by 4 = 966 + 0b111_0000 967 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_left by 4 = 968 + 0b1111_1111_1111_1111_1111_1111_1111_0000 969 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_left by 4 = 970 + 0b1111_1111_1111_1111_1111_1111_1101_0000 971 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_left by 4 = 972 + 0b1111_1111_1111_1111_1111_1111_1111_0000 973 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_left by 4 = 974 + 0b0 975 + 0b0 Int32.shift_left by 31 = 976 + 0b0 977 + 0b1 Int32.shift_left by 31 = 978 + 0b1000_0000_0000_0000_0000_0000_0000_0000 979 + 0b101 Int32.shift_left by 31 = 980 + 0b1000_0000_0000_0000_0000_0000_0000_0000 981 + 0b111 Int32.shift_left by 31 = 982 + 0b1000_0000_0000_0000_0000_0000_0000_0000 983 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_left by 31 = 984 + 0b1000_0000_0000_0000_0000_0000_0000_0000 985 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_left by 31 = 986 + 0b1000_0000_0000_0000_0000_0000_0000_0000 987 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_left by 31 = 988 + 0b1000_0000_0000_0000_0000_0000_0000_0000 989 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_left by 31 = 990 + 0b0 991 + 0b0 Int32.shift_left by 32 = 992 + 0b0 993 + 0b1 Int32.shift_left by 32 = 994 + 0b1 995 + 0b101 Int32.shift_left by 32 = 996 + 0b101 997 + 0b111 Int32.shift_left by 32 = 998 + 0b111 999 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_left by 32 = 1000 + 0b1111_1111_1111_1111_1111_1111_1111_1111 1001 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_left by 32 = 1002 + 0b1111_1111_1111_1111_1111_1111_1111_1101 1003 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_left by 32 = 1004 + 0b111_1111_1111_1111_1111_1111_1111_1111 1005 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_left by 32 = 1006 + 0b1000_0000_0000_0000_0000_0000_0000_0000 1007 + 0b0 Int32.shift_left by 33 = 1008 + 0b0 1009 + 0b1 Int32.shift_left by 33 = 1010 + 0b10 1011 + 0b101 Int32.shift_left by 33 = 1012 + 0b1010 1013 + 0b111 Int32.shift_left by 33 = 1014 + 0b1110 1015 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_left by 33 = 1016 + 0b1111_1111_1111_1111_1111_1111_1111_1110 1017 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_left by 33 = 1018 + 0b1111_1111_1111_1111_1111_1111_1111_1010 1019 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_left by 33 = 1020 + 0b1111_1111_1111_1111_1111_1111_1111_1110 1021 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_left by 33 = 1022 + 0b0 1023 + 0b0 Int32.shift_left by 62 = 1024 + 0b0 1025 + 0b1 Int32.shift_left by 62 = 1026 + 0b100_0000_0000_0000_0000_0000_0000_0000 1027 + 0b101 Int32.shift_left by 62 = 1028 + 0b100_0000_0000_0000_0000_0000_0000_0000 1029 + 0b111 Int32.shift_left by 62 = 1030 + 0b1100_0000_0000_0000_0000_0000_0000_0000 1031 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_left by 62 = 1032 + 0b1100_0000_0000_0000_0000_0000_0000_0000 1033 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_left by 62 = 1034 + 0b100_0000_0000_0000_0000_0000_0000_0000 1035 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_left by 62 = 1036 + 0b1100_0000_0000_0000_0000_0000_0000_0000 1037 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_left by 62 = 1038 + 0b0 1039 + 0b0 Int32.shift_left by 63 = 1040 + 0b0 1041 + 0b1 Int32.shift_left by 63 = 1042 + 0b1000_0000_0000_0000_0000_0000_0000_0000 1043 + 0b101 Int32.shift_left by 63 = 1044 + 0b1000_0000_0000_0000_0000_0000_0000_0000 1045 + 0b111 Int32.shift_left by 63 = 1046 + 0b1000_0000_0000_0000_0000_0000_0000_0000 1047 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_left by 63 = 1048 + 0b1000_0000_0000_0000_0000_0000_0000_0000 1049 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_left by 63 = 1050 + 0b1000_0000_0000_0000_0000_0000_0000_0000 1051 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_left by 63 = 1052 + 0b1000_0000_0000_0000_0000_0000_0000_0000 1053 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_left by 63 = 1054 + 0b0 1055 + 0b0 Int32.shift_left by 64 = 1056 + 0b0 1057 + 0b1 Int32.shift_left by 64 = 1058 + 0b1 1059 + 0b101 Int32.shift_left by 64 = 1060 + 0b101 1061 + 0b111 Int32.shift_left by 64 = 1062 + 0b111 1063 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_left by 64 = 1064 + 0b1111_1111_1111_1111_1111_1111_1111_1111 1065 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_left by 64 = 1066 + 0b1111_1111_1111_1111_1111_1111_1111_1101 1067 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_left by 64 = 1068 + 0b111_1111_1111_1111_1111_1111_1111_1111 1069 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_left by 64 = 1070 + 0b1000_0000_0000_0000_0000_0000_0000_0000 1071 + 0b0 Int32.shift_left by 65 = 1072 + 0b0 1073 + 0b1 Int32.shift_left by 65 = 1074 + 0b10 1075 + 0b101 Int32.shift_left by 65 = 1076 + 0b1010 1077 + 0b111 Int32.shift_left by 65 = 1078 + 0b1110 1079 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_left by 65 = 1080 + 0b1111_1111_1111_1111_1111_1111_1111_1110 1081 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_left by 65 = 1082 + 0b1111_1111_1111_1111_1111_1111_1111_1010 1083 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_left by 65 = 1084 + 0b1111_1111_1111_1111_1111_1111_1111_1110 1085 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_left by 65 = 1086 + 0b0 1087 + 0b0 Int32.shift_left by 66 = 1088 + 0b0 1089 + 0b1 Int32.shift_left by 66 = 1090 + 0b100 1091 + 0b101 Int32.shift_left by 66 = 1092 + 0b1_0100 1093 + 0b111 Int32.shift_left by 66 = 1094 + 0b1_1100 1095 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_left by 66 = 1096 + 0b1111_1111_1111_1111_1111_1111_1111_1100 1097 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_left by 66 = 1098 + 0b1111_1111_1111_1111_1111_1111_1111_0100 1099 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_left by 66 = 1100 + 0b1111_1111_1111_1111_1111_1111_1111_1100 1101 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_left by 66 = 1102 + 0b0 1103 + 0b0 Int32.shift_left by -1 = 1104 + 0b0 1105 + 0b1 Int32.shift_left by -1 = 1106 + 0b1000_0000_0000_0000_0000_0000_0000_0000 1107 + 0b101 Int32.shift_left by -1 = 1108 + 0b1000_0000_0000_0000_0000_0000_0000_0000 1109 + 0b111 Int32.shift_left by -1 = 1110 + 0b1000_0000_0000_0000_0000_0000_0000_0000 1111 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_left by -1 = 1112 + 0b1000_0000_0000_0000_0000_0000_0000_0000 1113 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_left by -1 = 1114 + 0b1000_0000_0000_0000_0000_0000_0000_0000 1115 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_left by -1 = 1116 + 0b1000_0000_0000_0000_0000_0000_0000_0000 1117 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_left by -1 = 1118 + 0b0 1119 + 0b0 Int32.shift_left by -3 = 1120 + 0b0 1121 + 0b1 Int32.shift_left by -3 = 1122 + 0b10_0000_0000_0000_0000_0000_0000_0000 1123 + 0b101 Int32.shift_left by -3 = 1124 + 0b1010_0000_0000_0000_0000_0000_0000_0000 1125 + 0b111 Int32.shift_left by -3 = 1126 + 0b1110_0000_0000_0000_0000_0000_0000_0000 1127 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_left by -3 = 1128 + 0b1110_0000_0000_0000_0000_0000_0000_0000 1129 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_left by -3 = 1130 + 0b1010_0000_0000_0000_0000_0000_0000_0000 1131 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_left by -3 = 1132 + 0b1110_0000_0000_0000_0000_0000_0000_0000 1133 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_left by -3 = 1134 + 0b0 1135 + 0b0 Int32.shift_left by 2_147_483_647 = 1136 + 0b0 1137 + 0b1 Int32.shift_left by 2_147_483_647 = 1138 + 0b1000_0000_0000_0000_0000_0000_0000_0000 1139 + 0b101 Int32.shift_left by 2_147_483_647 = 1140 + 0b1000_0000_0000_0000_0000_0000_0000_0000 1141 + 0b111 Int32.shift_left by 2_147_483_647 = 1142 + 0b1000_0000_0000_0000_0000_0000_0000_0000 1143 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_left by 2_147_483_647 = 1144 + 0b1000_0000_0000_0000_0000_0000_0000_0000 1145 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_left by 2_147_483_647 = 1146 + 0b1000_0000_0000_0000_0000_0000_0000_0000 1147 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_left by 2_147_483_647 = 1148 + 0b1000_0000_0000_0000_0000_0000_0000_0000 1149 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_left by 2_147_483_647 = 1150 + 0b0 1151 + 0b0 Int32.shift_left by -2_147_483_648 = 1152 + 0b0 1153 + 0b1 Int32.shift_left by -2_147_483_648 = 1154 + 0b1 1155 + 0b101 Int32.shift_left by -2_147_483_648 = 1156 + 0b101 1157 + 0b111 Int32.shift_left by -2_147_483_648 = 1158 + 0b111 1159 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_left by -2_147_483_648 = 1160 + 0b1111_1111_1111_1111_1111_1111_1111_1111 1161 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_left by -2_147_483_648 = 1162 + 0b1111_1111_1111_1111_1111_1111_1111_1101 1163 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_left by -2_147_483_648 = 1164 + 0b111_1111_1111_1111_1111_1111_1111_1111 1165 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_left by -2_147_483_648 = 1166 + 0b1000_0000_0000_0000_0000_0000_0000_0000 1167 + |}]; 1168 + () 1169 + ;; 1170 + 1171 + let%expect_test "shift_right int32" = 1172 + test 1173 + ~op:I.Int32.shift_right 1174 + ~expected_op:I.Int32.Naive.shift_right 1175 + ~name:"Int32.shift_right"; 1176 + [%expect 1177 + {| 1178 + 0b0 Int32.shift_right by 0 = 1179 + 0b0 1180 + 0b1 Int32.shift_right by 0 = 1181 + 0b1 1182 + 0b101 Int32.shift_right by 0 = 1183 + 0b101 1184 + 0b111 Int32.shift_right by 0 = 1185 + 0b111 1186 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right by 0 = 1187 + 0b1111_1111_1111_1111_1111_1111_1111_1111 1188 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_right by 0 = 1189 + 0b1111_1111_1111_1111_1111_1111_1111_1101 1190 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right by 0 = 1191 + 0b111_1111_1111_1111_1111_1111_1111_1111 1192 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_right by 0 = 1193 + 0b1000_0000_0000_0000_0000_0000_0000_0000 1194 + 0b0 Int32.shift_right by 1 = 1195 + 0b0 1196 + 0b1 Int32.shift_right by 1 = 1197 + 0b0 1198 + 0b101 Int32.shift_right by 1 = 1199 + 0b10 1200 + 0b111 Int32.shift_right by 1 = 1201 + 0b11 1202 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right by 1 = 1203 + 0b1111_1111_1111_1111_1111_1111_1111_1111 1204 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_right by 1 = 1205 + 0b1111_1111_1111_1111_1111_1111_1111_1110 1206 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right by 1 = 1207 + 0b11_1111_1111_1111_1111_1111_1111_1111 1208 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_right by 1 = 1209 + 0b1100_0000_0000_0000_0000_0000_0000_0000 1210 + 0b0 Int32.shift_right by 2 = 1211 + 0b0 1212 + 0b1 Int32.shift_right by 2 = 1213 + 0b0 1214 + 0b101 Int32.shift_right by 2 = 1215 + 0b1 1216 + 0b111 Int32.shift_right by 2 = 1217 + 0b1 1218 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right by 2 = 1219 + 0b1111_1111_1111_1111_1111_1111_1111_1111 1220 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_right by 2 = 1221 + 0b1111_1111_1111_1111_1111_1111_1111_1111 1222 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right by 2 = 1223 + 0b1_1111_1111_1111_1111_1111_1111_1111 1224 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_right by 2 = 1225 + 0b1110_0000_0000_0000_0000_0000_0000_0000 1226 + 0b0 Int32.shift_right by 3 = 1227 + 0b0 1228 + 0b1 Int32.shift_right by 3 = 1229 + 0b0 1230 + 0b101 Int32.shift_right by 3 = 1231 + 0b0 1232 + 0b111 Int32.shift_right by 3 = 1233 + 0b0 1234 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right by 3 = 1235 + 0b1111_1111_1111_1111_1111_1111_1111_1111 1236 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_right by 3 = 1237 + 0b1111_1111_1111_1111_1111_1111_1111_1111 1238 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right by 3 = 1239 + 0b1111_1111_1111_1111_1111_1111_1111 1240 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_right by 3 = 1241 + 0b1111_0000_0000_0000_0000_0000_0000_0000 1242 + 0b0 Int32.shift_right by 4 = 1243 + 0b0 1244 + 0b1 Int32.shift_right by 4 = 1245 + 0b0 1246 + 0b101 Int32.shift_right by 4 = 1247 + 0b0 1248 + 0b111 Int32.shift_right by 4 = 1249 + 0b0 1250 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right by 4 = 1251 + 0b1111_1111_1111_1111_1111_1111_1111_1111 1252 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_right by 4 = 1253 + 0b1111_1111_1111_1111_1111_1111_1111_1111 1254 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right by 4 = 1255 + 0b111_1111_1111_1111_1111_1111_1111 1256 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_right by 4 = 1257 + 0b1111_1000_0000_0000_0000_0000_0000_0000 1258 + 0b0 Int32.shift_right by 31 = 1259 + 0b0 1260 + 0b1 Int32.shift_right by 31 = 1261 + 0b0 1262 + 0b101 Int32.shift_right by 31 = 1263 + 0b0 1264 + 0b111 Int32.shift_right by 31 = 1265 + 0b0 1266 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right by 31 = 1267 + 0b1111_1111_1111_1111_1111_1111_1111_1111 1268 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_right by 31 = 1269 + 0b1111_1111_1111_1111_1111_1111_1111_1111 1270 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right by 31 = 1271 + 0b0 1272 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_right by 31 = 1273 + 0b1111_1111_1111_1111_1111_1111_1111_1111 1274 + 0b0 Int32.shift_right by 32 = 1275 + 0b0 1276 + 0b1 Int32.shift_right by 32 = 1277 + 0b1 1278 + 0b101 Int32.shift_right by 32 = 1279 + 0b101 1280 + 0b111 Int32.shift_right by 32 = 1281 + 0b111 1282 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right by 32 = 1283 + 0b1111_1111_1111_1111_1111_1111_1111_1111 1284 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_right by 32 = 1285 + 0b1111_1111_1111_1111_1111_1111_1111_1101 1286 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right by 32 = 1287 + 0b111_1111_1111_1111_1111_1111_1111_1111 1288 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_right by 32 = 1289 + 0b1000_0000_0000_0000_0000_0000_0000_0000 1290 + 0b0 Int32.shift_right by 33 = 1291 + 0b0 1292 + 0b1 Int32.shift_right by 33 = 1293 + 0b0 1294 + 0b101 Int32.shift_right by 33 = 1295 + 0b10 1296 + 0b111 Int32.shift_right by 33 = 1297 + 0b11 1298 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right by 33 = 1299 + 0b1111_1111_1111_1111_1111_1111_1111_1111 1300 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_right by 33 = 1301 + 0b1111_1111_1111_1111_1111_1111_1111_1110 1302 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right by 33 = 1303 + 0b11_1111_1111_1111_1111_1111_1111_1111 1304 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_right by 33 = 1305 + 0b1100_0000_0000_0000_0000_0000_0000_0000 1306 + 0b0 Int32.shift_right by 62 = 1307 + 0b0 1308 + 0b1 Int32.shift_right by 62 = 1309 + 0b0 1310 + 0b101 Int32.shift_right by 62 = 1311 + 0b0 1312 + 0b111 Int32.shift_right by 62 = 1313 + 0b0 1314 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right by 62 = 1315 + 0b1111_1111_1111_1111_1111_1111_1111_1111 1316 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_right by 62 = 1317 + 0b1111_1111_1111_1111_1111_1111_1111_1111 1318 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right by 62 = 1319 + 0b1 1320 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_right by 62 = 1321 + 0b1111_1111_1111_1111_1111_1111_1111_1110 1322 + 0b0 Int32.shift_right by 63 = 1323 + 0b0 1324 + 0b1 Int32.shift_right by 63 = 1325 + 0b0 1326 + 0b101 Int32.shift_right by 63 = 1327 + 0b0 1328 + 0b111 Int32.shift_right by 63 = 1329 + 0b0 1330 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right by 63 = 1331 + 0b1111_1111_1111_1111_1111_1111_1111_1111 1332 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_right by 63 = 1333 + 0b1111_1111_1111_1111_1111_1111_1111_1111 1334 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right by 63 = 1335 + 0b0 1336 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_right by 63 = 1337 + 0b1111_1111_1111_1111_1111_1111_1111_1111 1338 + 0b0 Int32.shift_right by 64 = 1339 + 0b0 1340 + 0b1 Int32.shift_right by 64 = 1341 + 0b1 1342 + 0b101 Int32.shift_right by 64 = 1343 + 0b101 1344 + 0b111 Int32.shift_right by 64 = 1345 + 0b111 1346 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right by 64 = 1347 + 0b1111_1111_1111_1111_1111_1111_1111_1111 1348 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_right by 64 = 1349 + 0b1111_1111_1111_1111_1111_1111_1111_1101 1350 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right by 64 = 1351 + 0b111_1111_1111_1111_1111_1111_1111_1111 1352 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_right by 64 = 1353 + 0b1000_0000_0000_0000_0000_0000_0000_0000 1354 + 0b0 Int32.shift_right by 65 = 1355 + 0b0 1356 + 0b1 Int32.shift_right by 65 = 1357 + 0b0 1358 + 0b101 Int32.shift_right by 65 = 1359 + 0b10 1360 + 0b111 Int32.shift_right by 65 = 1361 + 0b11 1362 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right by 65 = 1363 + 0b1111_1111_1111_1111_1111_1111_1111_1111 1364 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_right by 65 = 1365 + 0b1111_1111_1111_1111_1111_1111_1111_1110 1366 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right by 65 = 1367 + 0b11_1111_1111_1111_1111_1111_1111_1111 1368 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_right by 65 = 1369 + 0b1100_0000_0000_0000_0000_0000_0000_0000 1370 + 0b0 Int32.shift_right by 66 = 1371 + 0b0 1372 + 0b1 Int32.shift_right by 66 = 1373 + 0b0 1374 + 0b101 Int32.shift_right by 66 = 1375 + 0b1 1376 + 0b111 Int32.shift_right by 66 = 1377 + 0b1 1378 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right by 66 = 1379 + 0b1111_1111_1111_1111_1111_1111_1111_1111 1380 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_right by 66 = 1381 + 0b1111_1111_1111_1111_1111_1111_1111_1111 1382 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right by 66 = 1383 + 0b1_1111_1111_1111_1111_1111_1111_1111 1384 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_right by 66 = 1385 + 0b1110_0000_0000_0000_0000_0000_0000_0000 1386 + 0b0 Int32.shift_right by -1 = 1387 + 0b0 1388 + 0b1 Int32.shift_right by -1 = 1389 + 0b0 1390 + 0b101 Int32.shift_right by -1 = 1391 + 0b0 1392 + 0b111 Int32.shift_right by -1 = 1393 + 0b0 1394 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right by -1 = 1395 + 0b1111_1111_1111_1111_1111_1111_1111_1111 1396 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_right by -1 = 1397 + 0b1111_1111_1111_1111_1111_1111_1111_1111 1398 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right by -1 = 1399 + 0b0 1400 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_right by -1 = 1401 + 0b1111_1111_1111_1111_1111_1111_1111_1111 1402 + 0b0 Int32.shift_right by -3 = 1403 + 0b0 1404 + 0b1 Int32.shift_right by -3 = 1405 + 0b0 1406 + 0b101 Int32.shift_right by -3 = 1407 + 0b0 1408 + 0b111 Int32.shift_right by -3 = 1409 + 0b0 1410 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right by -3 = 1411 + 0b1111_1111_1111_1111_1111_1111_1111_1111 1412 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_right by -3 = 1413 + 0b1111_1111_1111_1111_1111_1111_1111_1111 1414 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right by -3 = 1415 + 0b11 1416 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_right by -3 = 1417 + 0b1111_1111_1111_1111_1111_1111_1111_1100 1418 + 0b0 Int32.shift_right by 2_147_483_647 = 1419 + 0b0 1420 + 0b1 Int32.shift_right by 2_147_483_647 = 1421 + 0b0 1422 + 0b101 Int32.shift_right by 2_147_483_647 = 1423 + 0b0 1424 + 0b111 Int32.shift_right by 2_147_483_647 = 1425 + 0b0 1426 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right by 2_147_483_647 = 1427 + 0b1111_1111_1111_1111_1111_1111_1111_1111 1428 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_right by 2_147_483_647 = 1429 + 0b1111_1111_1111_1111_1111_1111_1111_1111 1430 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right by 2_147_483_647 = 1431 + 0b0 1432 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_right by 2_147_483_647 = 1433 + 0b1111_1111_1111_1111_1111_1111_1111_1111 1434 + 0b0 Int32.shift_right by -2_147_483_648 = 1435 + 0b0 1436 + 0b1 Int32.shift_right by -2_147_483_648 = 1437 + 0b1 1438 + 0b101 Int32.shift_right by -2_147_483_648 = 1439 + 0b101 1440 + 0b111 Int32.shift_right by -2_147_483_648 = 1441 + 0b111 1442 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right by -2_147_483_648 = 1443 + 0b1111_1111_1111_1111_1111_1111_1111_1111 1444 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_right by -2_147_483_648 = 1445 + 0b1111_1111_1111_1111_1111_1111_1111_1101 1446 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right by -2_147_483_648 = 1447 + 0b111_1111_1111_1111_1111_1111_1111_1111 1448 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_right by -2_147_483_648 = 1449 + 0b1000_0000_0000_0000_0000_0000_0000_0000 1450 + |}]; 1451 + () 1452 + ;; 1453 + 1454 + let%expect_test "shift_right_logical int32" = 1455 + test 1456 + ~op:I.Int32.shift_right_logical 1457 + ~expected_op:I.Int32.Naive.shift_right_logical 1458 + ~name:"Int32.shift_right_logical"; 1459 + [%expect 1460 + {| 1461 + 0b0 Int32.shift_right_logical by 0 = 1462 + 0b0 1463 + 0b1 Int32.shift_right_logical by 0 = 1464 + 0b1 1465 + 0b101 Int32.shift_right_logical by 0 = 1466 + 0b101 1467 + 0b111 Int32.shift_right_logical by 0 = 1468 + 0b111 1469 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right_logical by 0 = 1470 + 0b1111_1111_1111_1111_1111_1111_1111_1111 1471 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_right_logical by 0 = 1472 + 0b1111_1111_1111_1111_1111_1111_1111_1101 1473 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right_logical by 0 = 1474 + 0b111_1111_1111_1111_1111_1111_1111_1111 1475 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_right_logical by 0 = 1476 + 0b1000_0000_0000_0000_0000_0000_0000_0000 1477 + 0b0 Int32.shift_right_logical by 1 = 1478 + 0b0 1479 + 0b1 Int32.shift_right_logical by 1 = 1480 + 0b0 1481 + 0b101 Int32.shift_right_logical by 1 = 1482 + 0b10 1483 + 0b111 Int32.shift_right_logical by 1 = 1484 + 0b11 1485 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right_logical by 1 = 1486 + 0b111_1111_1111_1111_1111_1111_1111_1111 1487 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_right_logical by 1 = 1488 + 0b111_1111_1111_1111_1111_1111_1111_1110 1489 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right_logical by 1 = 1490 + 0b11_1111_1111_1111_1111_1111_1111_1111 1491 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_right_logical by 1 = 1492 + 0b100_0000_0000_0000_0000_0000_0000_0000 1493 + 0b0 Int32.shift_right_logical by 2 = 1494 + 0b0 1495 + 0b1 Int32.shift_right_logical by 2 = 1496 + 0b0 1497 + 0b101 Int32.shift_right_logical by 2 = 1498 + 0b1 1499 + 0b111 Int32.shift_right_logical by 2 = 1500 + 0b1 1501 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right_logical by 2 = 1502 + 0b11_1111_1111_1111_1111_1111_1111_1111 1503 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_right_logical by 2 = 1504 + 0b11_1111_1111_1111_1111_1111_1111_1111 1505 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right_logical by 2 = 1506 + 0b1_1111_1111_1111_1111_1111_1111_1111 1507 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_right_logical by 2 = 1508 + 0b10_0000_0000_0000_0000_0000_0000_0000 1509 + 0b0 Int32.shift_right_logical by 3 = 1510 + 0b0 1511 + 0b1 Int32.shift_right_logical by 3 = 1512 + 0b0 1513 + 0b101 Int32.shift_right_logical by 3 = 1514 + 0b0 1515 + 0b111 Int32.shift_right_logical by 3 = 1516 + 0b0 1517 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right_logical by 3 = 1518 + 0b1_1111_1111_1111_1111_1111_1111_1111 1519 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_right_logical by 3 = 1520 + 0b1_1111_1111_1111_1111_1111_1111_1111 1521 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right_logical by 3 = 1522 + 0b1111_1111_1111_1111_1111_1111_1111 1523 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_right_logical by 3 = 1524 + 0b1_0000_0000_0000_0000_0000_0000_0000 1525 + 0b0 Int32.shift_right_logical by 4 = 1526 + 0b0 1527 + 0b1 Int32.shift_right_logical by 4 = 1528 + 0b0 1529 + 0b101 Int32.shift_right_logical by 4 = 1530 + 0b0 1531 + 0b111 Int32.shift_right_logical by 4 = 1532 + 0b0 1533 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right_logical by 4 = 1534 + 0b1111_1111_1111_1111_1111_1111_1111 1535 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_right_logical by 4 = 1536 + 0b1111_1111_1111_1111_1111_1111_1111 1537 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right_logical by 4 = 1538 + 0b111_1111_1111_1111_1111_1111_1111 1539 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_right_logical by 4 = 1540 + 0b1000_0000_0000_0000_0000_0000_0000 1541 + 0b0 Int32.shift_right_logical by 31 = 1542 + 0b0 1543 + 0b1 Int32.shift_right_logical by 31 = 1544 + 0b0 1545 + 0b101 Int32.shift_right_logical by 31 = 1546 + 0b0 1547 + 0b111 Int32.shift_right_logical by 31 = 1548 + 0b0 1549 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right_logical by 31 = 1550 + 0b1 1551 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_right_logical by 31 = 1552 + 0b1 1553 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right_logical by 31 = 1554 + 0b0 1555 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_right_logical by 31 = 1556 + 0b1 1557 + 0b0 Int32.shift_right_logical by 32 = 1558 + 0b0 1559 + 0b1 Int32.shift_right_logical by 32 = 1560 + 0b1 1561 + 0b101 Int32.shift_right_logical by 32 = 1562 + 0b101 1563 + 0b111 Int32.shift_right_logical by 32 = 1564 + 0b111 1565 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right_logical by 32 = 1566 + 0b1111_1111_1111_1111_1111_1111_1111_1111 1567 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_right_logical by 32 = 1568 + 0b1111_1111_1111_1111_1111_1111_1111_1101 1569 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right_logical by 32 = 1570 + 0b111_1111_1111_1111_1111_1111_1111_1111 1571 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_right_logical by 32 = 1572 + 0b1000_0000_0000_0000_0000_0000_0000_0000 1573 + 0b0 Int32.shift_right_logical by 33 = 1574 + 0b0 1575 + 0b1 Int32.shift_right_logical by 33 = 1576 + 0b0 1577 + 0b101 Int32.shift_right_logical by 33 = 1578 + 0b10 1579 + 0b111 Int32.shift_right_logical by 33 = 1580 + 0b11 1581 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right_logical by 33 = 1582 + 0b111_1111_1111_1111_1111_1111_1111_1111 1583 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_right_logical by 33 = 1584 + 0b111_1111_1111_1111_1111_1111_1111_1110 1585 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right_logical by 33 = 1586 + 0b11_1111_1111_1111_1111_1111_1111_1111 1587 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_right_logical by 33 = 1588 + 0b100_0000_0000_0000_0000_0000_0000_0000 1589 + 0b0 Int32.shift_right_logical by 62 = 1590 + 0b0 1591 + 0b1 Int32.shift_right_logical by 62 = 1592 + 0b0 1593 + 0b101 Int32.shift_right_logical by 62 = 1594 + 0b0 1595 + 0b111 Int32.shift_right_logical by 62 = 1596 + 0b0 1597 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right_logical by 62 = 1598 + 0b11 1599 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_right_logical by 62 = 1600 + 0b11 1601 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right_logical by 62 = 1602 + 0b1 1603 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_right_logical by 62 = 1604 + 0b10 1605 + 0b0 Int32.shift_right_logical by 63 = 1606 + 0b0 1607 + 0b1 Int32.shift_right_logical by 63 = 1608 + 0b0 1609 + 0b101 Int32.shift_right_logical by 63 = 1610 + 0b0 1611 + 0b111 Int32.shift_right_logical by 63 = 1612 + 0b0 1613 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right_logical by 63 = 1614 + 0b1 1615 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_right_logical by 63 = 1616 + 0b1 1617 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right_logical by 63 = 1618 + 0b0 1619 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_right_logical by 63 = 1620 + 0b1 1621 + 0b0 Int32.shift_right_logical by 64 = 1622 + 0b0 1623 + 0b1 Int32.shift_right_logical by 64 = 1624 + 0b1 1625 + 0b101 Int32.shift_right_logical by 64 = 1626 + 0b101 1627 + 0b111 Int32.shift_right_logical by 64 = 1628 + 0b111 1629 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right_logical by 64 = 1630 + 0b1111_1111_1111_1111_1111_1111_1111_1111 1631 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_right_logical by 64 = 1632 + 0b1111_1111_1111_1111_1111_1111_1111_1101 1633 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right_logical by 64 = 1634 + 0b111_1111_1111_1111_1111_1111_1111_1111 1635 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_right_logical by 64 = 1636 + 0b1000_0000_0000_0000_0000_0000_0000_0000 1637 + 0b0 Int32.shift_right_logical by 65 = 1638 + 0b0 1639 + 0b1 Int32.shift_right_logical by 65 = 1640 + 0b0 1641 + 0b101 Int32.shift_right_logical by 65 = 1642 + 0b10 1643 + 0b111 Int32.shift_right_logical by 65 = 1644 + 0b11 1645 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right_logical by 65 = 1646 + 0b111_1111_1111_1111_1111_1111_1111_1111 1647 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_right_logical by 65 = 1648 + 0b111_1111_1111_1111_1111_1111_1111_1110 1649 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right_logical by 65 = 1650 + 0b11_1111_1111_1111_1111_1111_1111_1111 1651 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_right_logical by 65 = 1652 + 0b100_0000_0000_0000_0000_0000_0000_0000 1653 + 0b0 Int32.shift_right_logical by 66 = 1654 + 0b0 1655 + 0b1 Int32.shift_right_logical by 66 = 1656 + 0b0 1657 + 0b101 Int32.shift_right_logical by 66 = 1658 + 0b1 1659 + 0b111 Int32.shift_right_logical by 66 = 1660 + 0b1 1661 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right_logical by 66 = 1662 + 0b11_1111_1111_1111_1111_1111_1111_1111 1663 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_right_logical by 66 = 1664 + 0b11_1111_1111_1111_1111_1111_1111_1111 1665 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right_logical by 66 = 1666 + 0b1_1111_1111_1111_1111_1111_1111_1111 1667 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_right_logical by 66 = 1668 + 0b10_0000_0000_0000_0000_0000_0000_0000 1669 + 0b0 Int32.shift_right_logical by -1 = 1670 + 0b0 1671 + 0b1 Int32.shift_right_logical by -1 = 1672 + 0b0 1673 + 0b101 Int32.shift_right_logical by -1 = 1674 + 0b0 1675 + 0b111 Int32.shift_right_logical by -1 = 1676 + 0b0 1677 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right_logical by -1 = 1678 + 0b1 1679 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_right_logical by -1 = 1680 + 0b1 1681 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right_logical by -1 = 1682 + 0b0 1683 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_right_logical by -1 = 1684 + 0b1 1685 + 0b0 Int32.shift_right_logical by -3 = 1686 + 0b0 1687 + 0b1 Int32.shift_right_logical by -3 = 1688 + 0b0 1689 + 0b101 Int32.shift_right_logical by -3 = 1690 + 0b0 1691 + 0b111 Int32.shift_right_logical by -3 = 1692 + 0b0 1693 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right_logical by -3 = 1694 + 0b111 1695 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_right_logical by -3 = 1696 + 0b111 1697 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right_logical by -3 = 1698 + 0b11 1699 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_right_logical by -3 = 1700 + 0b100 1701 + 0b0 Int32.shift_right_logical by 2_147_483_647 = 1702 + 0b0 1703 + 0b1 Int32.shift_right_logical by 2_147_483_647 = 1704 + 0b0 1705 + 0b101 Int32.shift_right_logical by 2_147_483_647 = 1706 + 0b0 1707 + 0b111 Int32.shift_right_logical by 2_147_483_647 = 1708 + 0b0 1709 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right_logical by 2_147_483_647 = 1710 + 0b1 1711 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_right_logical by 2_147_483_647 = 1712 + 0b1 1713 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right_logical by 2_147_483_647 = 1714 + 0b0 1715 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_right_logical by 2_147_483_647 = 1716 + 0b1 1717 + 0b0 Int32.shift_right_logical by -2_147_483_648 = 1718 + 0b0 1719 + 0b1 Int32.shift_right_logical by -2_147_483_648 = 1720 + 0b1 1721 + 0b101 Int32.shift_right_logical by -2_147_483_648 = 1722 + 0b101 1723 + 0b111 Int32.shift_right_logical by -2_147_483_648 = 1724 + 0b111 1725 + 0b1111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right_logical by -2_147_483_648 = 1726 + 0b1111_1111_1111_1111_1111_1111_1111_1111 1727 + 0b1111_1111_1111_1111_1111_1111_1111_1101 Int32.shift_right_logical by -2_147_483_648 = 1728 + 0b1111_1111_1111_1111_1111_1111_1111_1101 1729 + 0b111_1111_1111_1111_1111_1111_1111_1111 Int32.shift_right_logical by -2_147_483_648 = 1730 + 0b111_1111_1111_1111_1111_1111_1111_1111 1731 + 0b1000_0000_0000_0000_0000_0000_0000_0000 Int32.shift_right_logical by -2_147_483_648 = 1732 + 0b1000_0000_0000_0000_0000_0000_0000_0000 1733 + |}]; 1734 + () 1735 + ;; 1736 + end 1737 + 1738 + module%test [@tags "64-bits-only"] Nativeint_arch64 = struct 1739 + open Nativeint 1740 + 1741 + let numbers = List.map ~f:of_int_exn numbers @ [ max_value; min_value ] 1742 + let shifts = List.map ~f:of_int_exn shifts @ [ max_value; min_value ] 1743 + 1744 + let test ~op ~expected_op ~name = 1745 + let f ~shift x = 1746 + test_shifts (module Binary) (module Nativeint) ~op ~expected_op ~name x shift 1747 + in 1748 + List.iter shifts ~f:(fun shift -> 1749 + let f = f ~shift in 1750 + List.iter ~f numbers) 1751 + ;; 1752 + 1753 + let%expect_test "shift_left nativeint" = 1754 + test 1755 + ~op:I.Nativeint.shift_left 1756 + ~expected_op:I.Nativeint.Naive.shift_left 1757 + ~name:"Nativeint.shift_left"; 1758 + [%expect 1759 + {| 1760 + 0b0 Nativeint.shift_left by 0 = 1761 + 0b0 1762 + 0b1 Nativeint.shift_left by 0 = 1763 + 0b1 1764 + 0b101 Nativeint.shift_left by 0 = 1765 + 0b101 1766 + 0b111 Nativeint.shift_left by 0 = 1767 + 0b111 1768 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_left by 0 = 1769 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 1770 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_left by 0 = 1771 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 1772 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_left by 0 = 1773 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 1774 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_left by 0 = 1775 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 1776 + 0b0 Nativeint.shift_left by 1 = 1777 + 0b0 1778 + 0b1 Nativeint.shift_left by 1 = 1779 + 0b10 1780 + 0b101 Nativeint.shift_left by 1 = 1781 + 0b1010 1782 + 0b111 Nativeint.shift_left by 1 = 1783 + 0b1110 1784 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_left by 1 = 1785 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1110 1786 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_left by 1 = 1787 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1010 1788 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_left by 1 = 1789 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1110 1790 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_left by 1 = 1791 + 0b0 1792 + 0b0 Nativeint.shift_left by 2 = 1793 + 0b0 1794 + 0b1 Nativeint.shift_left by 2 = 1795 + 0b100 1796 + 0b101 Nativeint.shift_left by 2 = 1797 + 0b1_0100 1798 + 0b111 Nativeint.shift_left by 2 = 1799 + 0b1_1100 1800 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_left by 2 = 1801 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1100 1802 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_left by 2 = 1803 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_0100 1804 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_left by 2 = 1805 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1100 1806 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_left by 2 = 1807 + 0b0 1808 + 0b0 Nativeint.shift_left by 3 = 1809 + 0b0 1810 + 0b1 Nativeint.shift_left by 3 = 1811 + 0b1000 1812 + 0b101 Nativeint.shift_left by 3 = 1813 + 0b10_1000 1814 + 0b111 Nativeint.shift_left by 3 = 1815 + 0b11_1000 1816 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_left by 3 = 1817 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1000 1818 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_left by 3 = 1819 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1110_1000 1820 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_left by 3 = 1821 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1000 1822 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_left by 3 = 1823 + 0b0 1824 + 0b0 Nativeint.shift_left by 4 = 1825 + 0b0 1826 + 0b1 Nativeint.shift_left by 4 = 1827 + 0b1_0000 1828 + 0b101 Nativeint.shift_left by 4 = 1829 + 0b101_0000 1830 + 0b111 Nativeint.shift_left by 4 = 1831 + 0b111_0000 1832 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_left by 4 = 1833 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_0000 1834 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_left by 4 = 1835 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101_0000 1836 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_left by 4 = 1837 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_0000 1838 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_left by 4 = 1839 + 0b0 1840 + 0b0 Nativeint.shift_left by 31 = 1841 + 0b0 1842 + 0b1 Nativeint.shift_left by 31 = 1843 + 0b1000_0000_0000_0000_0000_0000_0000_0000 1844 + 0b101 Nativeint.shift_left by 31 = 1845 + 0b10_1000_0000_0000_0000_0000_0000_0000_0000 1846 + 0b111 Nativeint.shift_left by 31 = 1847 + 0b11_1000_0000_0000_0000_0000_0000_0000_0000 1848 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_left by 31 = 1849 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1000_0000_0000_0000_0000_0000_0000_0000 1850 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_left by 31 = 1851 + 0b1111_1111_1111_1111_1111_1111_1111_1110_1000_0000_0000_0000_0000_0000_0000_0000 1852 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_left by 31 = 1853 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1000_0000_0000_0000_0000_0000_0000_0000 1854 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_left by 31 = 1855 + 0b0 1856 + 0b0 Nativeint.shift_left by 32 = 1857 + 0b0 1858 + 0b1 Nativeint.shift_left by 32 = 1859 + 0b1_0000_0000_0000_0000_0000_0000_0000_0000 1860 + 0b101 Nativeint.shift_left by 32 = 1861 + 0b101_0000_0000_0000_0000_0000_0000_0000_0000 1862 + 0b111 Nativeint.shift_left by 32 = 1863 + 0b111_0000_0000_0000_0000_0000_0000_0000_0000 1864 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_left by 32 = 1865 + 0b1111_1111_1111_1111_1111_1111_1111_1111_0000_0000_0000_0000_0000_0000_0000_0000 1866 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_left by 32 = 1867 + 0b1111_1111_1111_1111_1111_1111_1111_1101_0000_0000_0000_0000_0000_0000_0000_0000 1868 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_left by 32 = 1869 + 0b1111_1111_1111_1111_1111_1111_1111_1111_0000_0000_0000_0000_0000_0000_0000_0000 1870 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_left by 32 = 1871 + 0b0 1872 + 0b0 Nativeint.shift_left by 33 = 1873 + 0b0 1874 + 0b1 Nativeint.shift_left by 33 = 1875 + 0b10_0000_0000_0000_0000_0000_0000_0000_0000 1876 + 0b101 Nativeint.shift_left by 33 = 1877 + 0b1010_0000_0000_0000_0000_0000_0000_0000_0000 1878 + 0b111 Nativeint.shift_left by 33 = 1879 + 0b1110_0000_0000_0000_0000_0000_0000_0000_0000 1880 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_left by 33 = 1881 + 0b1111_1111_1111_1111_1111_1111_1111_1110_0000_0000_0000_0000_0000_0000_0000_0000 1882 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_left by 33 = 1883 + 0b1111_1111_1111_1111_1111_1111_1111_1010_0000_0000_0000_0000_0000_0000_0000_0000 1884 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_left by 33 = 1885 + 0b1111_1111_1111_1111_1111_1111_1111_1110_0000_0000_0000_0000_0000_0000_0000_0000 1886 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_left by 33 = 1887 + 0b0 1888 + 0b0 Nativeint.shift_left by 62 = 1889 + 0b0 1890 + 0b1 Nativeint.shift_left by 62 = 1891 + 0b100_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 1892 + 0b101 Nativeint.shift_left by 62 = 1893 + 0b100_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 1894 + 0b111 Nativeint.shift_left by 62 = 1895 + 0b1100_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 1896 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_left by 62 = 1897 + 0b1100_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 1898 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_left by 62 = 1899 + 0b100_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 1900 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_left by 62 = 1901 + 0b1100_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 1902 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_left by 62 = 1903 + 0b0 1904 + 0b0 Nativeint.shift_left by 63 = 1905 + 0b0 1906 + 0b1 Nativeint.shift_left by 63 = 1907 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 1908 + 0b101 Nativeint.shift_left by 63 = 1909 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 1910 + 0b111 Nativeint.shift_left by 63 = 1911 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 1912 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_left by 63 = 1913 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 1914 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_left by 63 = 1915 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 1916 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_left by 63 = 1917 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 1918 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_left by 63 = 1919 + 0b0 1920 + 0b0 Nativeint.shift_left by 64 = 1921 + 0b0 1922 + 0b1 Nativeint.shift_left by 64 = 1923 + 0b1 1924 + 0b101 Nativeint.shift_left by 64 = 1925 + 0b101 1926 + 0b111 Nativeint.shift_left by 64 = 1927 + 0b111 1928 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_left by 64 = 1929 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 1930 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_left by 64 = 1931 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 1932 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_left by 64 = 1933 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 1934 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_left by 64 = 1935 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 1936 + 0b0 Nativeint.shift_left by 65 = 1937 + 0b0 1938 + 0b1 Nativeint.shift_left by 65 = 1939 + 0b10 1940 + 0b101 Nativeint.shift_left by 65 = 1941 + 0b1010 1942 + 0b111 Nativeint.shift_left by 65 = 1943 + 0b1110 1944 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_left by 65 = 1945 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1110 1946 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_left by 65 = 1947 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1010 1948 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_left by 65 = 1949 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1110 1950 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_left by 65 = 1951 + 0b0 1952 + 0b0 Nativeint.shift_left by 66 = 1953 + 0b0 1954 + 0b1 Nativeint.shift_left by 66 = 1955 + 0b100 1956 + 0b101 Nativeint.shift_left by 66 = 1957 + 0b1_0100 1958 + 0b111 Nativeint.shift_left by 66 = 1959 + 0b1_1100 1960 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_left by 66 = 1961 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1100 1962 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_left by 66 = 1963 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_0100 1964 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_left by 66 = 1965 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1100 1966 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_left by 66 = 1967 + 0b0 1968 + 0b0 Nativeint.shift_left by -1 = 1969 + 0b0 1970 + 0b1 Nativeint.shift_left by -1 = 1971 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 1972 + 0b101 Nativeint.shift_left by -1 = 1973 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 1974 + 0b111 Nativeint.shift_left by -1 = 1975 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 1976 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_left by -1 = 1977 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 1978 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_left by -1 = 1979 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 1980 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_left by -1 = 1981 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 1982 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_left by -1 = 1983 + 0b0 1984 + 0b0 Nativeint.shift_left by -3 = 1985 + 0b0 1986 + 0b1 Nativeint.shift_left by -3 = 1987 + 0b10_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 1988 + 0b101 Nativeint.shift_left by -3 = 1989 + 0b1010_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 1990 + 0b111 Nativeint.shift_left by -3 = 1991 + 0b1110_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 1992 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_left by -3 = 1993 + 0b1110_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 1994 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_left by -3 = 1995 + 0b1010_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 1996 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_left by -3 = 1997 + 0b1110_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 1998 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_left by -3 = 1999 + 0b0 2000 + 0b0 Nativeint.shift_left by 9_223_372_036_854_775_807 = 2001 + 0b0 2002 + 0b1 Nativeint.shift_left by 9_223_372_036_854_775_807 = 2003 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 2004 + 0b101 Nativeint.shift_left by 9_223_372_036_854_775_807 = 2005 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 2006 + 0b111 Nativeint.shift_left by 9_223_372_036_854_775_807 = 2007 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 2008 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_left by 9_223_372_036_854_775_807 = 2009 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 2010 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_left by 9_223_372_036_854_775_807 = 2011 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 2012 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_left by 9_223_372_036_854_775_807 = 2013 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 2014 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_left by 9_223_372_036_854_775_807 = 2015 + 0b0 2016 + 0b0 Nativeint.shift_left by -9_223_372_036_854_775_808 = 2017 + 0b0 2018 + 0b1 Nativeint.shift_left by -9_223_372_036_854_775_808 = 2019 + 0b1 2020 + 0b101 Nativeint.shift_left by -9_223_372_036_854_775_808 = 2021 + 0b101 2022 + 0b111 Nativeint.shift_left by -9_223_372_036_854_775_808 = 2023 + 0b111 2024 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_left by -9_223_372_036_854_775_808 = 2025 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2026 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_left by -9_223_372_036_854_775_808 = 2027 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 2028 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_left by -9_223_372_036_854_775_808 = 2029 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2030 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_left by -9_223_372_036_854_775_808 = 2031 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 2032 + |}]; 2033 + () 2034 + ;; 2035 + 2036 + let%expect_test "shift_right nativeint" = 2037 + test 2038 + ~op:I.Nativeint.shift_right 2039 + ~expected_op:I.Nativeint.Naive.shift_right 2040 + ~name:"Nativeint.shift_right"; 2041 + [%expect 2042 + {| 2043 + 0b0 Nativeint.shift_right by 0 = 2044 + 0b0 2045 + 0b1 Nativeint.shift_right by 0 = 2046 + 0b1 2047 + 0b101 Nativeint.shift_right by 0 = 2048 + 0b101 2049 + 0b111 Nativeint.shift_right by 0 = 2050 + 0b111 2051 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right by 0 = 2052 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2053 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_right by 0 = 2054 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 2055 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right by 0 = 2056 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2057 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_right by 0 = 2058 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 2059 + 0b0 Nativeint.shift_right by 1 = 2060 + 0b0 2061 + 0b1 Nativeint.shift_right by 1 = 2062 + 0b0 2063 + 0b101 Nativeint.shift_right by 1 = 2064 + 0b10 2065 + 0b111 Nativeint.shift_right by 1 = 2066 + 0b11 2067 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right by 1 = 2068 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2069 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_right by 1 = 2070 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1110 2071 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right by 1 = 2072 + 0b11_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2073 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_right by 1 = 2074 + 0b1100_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 2075 + 0b0 Nativeint.shift_right by 2 = 2076 + 0b0 2077 + 0b1 Nativeint.shift_right by 2 = 2078 + 0b0 2079 + 0b101 Nativeint.shift_right by 2 = 2080 + 0b1 2081 + 0b111 Nativeint.shift_right by 2 = 2082 + 0b1 2083 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right by 2 = 2084 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2085 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_right by 2 = 2086 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2087 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right by 2 = 2088 + 0b1_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2089 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_right by 2 = 2090 + 0b1110_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 2091 + 0b0 Nativeint.shift_right by 3 = 2092 + 0b0 2093 + 0b1 Nativeint.shift_right by 3 = 2094 + 0b0 2095 + 0b101 Nativeint.shift_right by 3 = 2096 + 0b0 2097 + 0b111 Nativeint.shift_right by 3 = 2098 + 0b0 2099 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right by 3 = 2100 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2101 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_right by 3 = 2102 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2103 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right by 3 = 2104 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2105 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_right by 3 = 2106 + 0b1111_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 2107 + 0b0 Nativeint.shift_right by 4 = 2108 + 0b0 2109 + 0b1 Nativeint.shift_right by 4 = 2110 + 0b0 2111 + 0b101 Nativeint.shift_right by 4 = 2112 + 0b0 2113 + 0b111 Nativeint.shift_right by 4 = 2114 + 0b0 2115 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right by 4 = 2116 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2117 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_right by 4 = 2118 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2119 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right by 4 = 2120 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2121 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_right by 4 = 2122 + 0b1111_1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 2123 + 0b0 Nativeint.shift_right by 31 = 2124 + 0b0 2125 + 0b1 Nativeint.shift_right by 31 = 2126 + 0b0 2127 + 0b101 Nativeint.shift_right by 31 = 2128 + 0b0 2129 + 0b111 Nativeint.shift_right by 31 = 2130 + 0b0 2131 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right by 31 = 2132 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2133 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_right by 31 = 2134 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2135 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right by 31 = 2136 + 0b1111_1111_1111_1111_1111_1111_1111_1111 2137 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_right by 31 = 2138 + 0b1111_1111_1111_1111_1111_1111_1111_1111_0000_0000_0000_0000_0000_0000_0000_0000 2139 + 0b0 Nativeint.shift_right by 32 = 2140 + 0b0 2141 + 0b1 Nativeint.shift_right by 32 = 2142 + 0b0 2143 + 0b101 Nativeint.shift_right by 32 = 2144 + 0b0 2145 + 0b111 Nativeint.shift_right by 32 = 2146 + 0b0 2147 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right by 32 = 2148 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2149 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_right by 32 = 2150 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2151 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right by 32 = 2152 + 0b111_1111_1111_1111_1111_1111_1111_1111 2153 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_right by 32 = 2154 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1000_0000_0000_0000_0000_0000_0000_0000 2155 + 0b0 Nativeint.shift_right by 33 = 2156 + 0b0 2157 + 0b1 Nativeint.shift_right by 33 = 2158 + 0b0 2159 + 0b101 Nativeint.shift_right by 33 = 2160 + 0b0 2161 + 0b111 Nativeint.shift_right by 33 = 2162 + 0b0 2163 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right by 33 = 2164 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2165 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_right by 33 = 2166 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2167 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right by 33 = 2168 + 0b11_1111_1111_1111_1111_1111_1111_1111 2169 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_right by 33 = 2170 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1100_0000_0000_0000_0000_0000_0000_0000 2171 + 0b0 Nativeint.shift_right by 62 = 2172 + 0b0 2173 + 0b1 Nativeint.shift_right by 62 = 2174 + 0b0 2175 + 0b101 Nativeint.shift_right by 62 = 2176 + 0b0 2177 + 0b111 Nativeint.shift_right by 62 = 2178 + 0b0 2179 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right by 62 = 2180 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2181 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_right by 62 = 2182 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2183 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right by 62 = 2184 + 0b1 2185 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_right by 62 = 2186 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1110 2187 + 0b0 Nativeint.shift_right by 63 = 2188 + 0b0 2189 + 0b1 Nativeint.shift_right by 63 = 2190 + 0b0 2191 + 0b101 Nativeint.shift_right by 63 = 2192 + 0b0 2193 + 0b111 Nativeint.shift_right by 63 = 2194 + 0b0 2195 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right by 63 = 2196 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2197 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_right by 63 = 2198 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2199 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right by 63 = 2200 + 0b0 2201 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_right by 63 = 2202 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2203 + 0b0 Nativeint.shift_right by 64 = 2204 + 0b0 2205 + 0b1 Nativeint.shift_right by 64 = 2206 + 0b1 2207 + 0b101 Nativeint.shift_right by 64 = 2208 + 0b101 2209 + 0b111 Nativeint.shift_right by 64 = 2210 + 0b111 2211 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right by 64 = 2212 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2213 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_right by 64 = 2214 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 2215 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right by 64 = 2216 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2217 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_right by 64 = 2218 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 2219 + 0b0 Nativeint.shift_right by 65 = 2220 + 0b0 2221 + 0b1 Nativeint.shift_right by 65 = 2222 + 0b0 2223 + 0b101 Nativeint.shift_right by 65 = 2224 + 0b10 2225 + 0b111 Nativeint.shift_right by 65 = 2226 + 0b11 2227 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right by 65 = 2228 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2229 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_right by 65 = 2230 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1110 2231 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right by 65 = 2232 + 0b11_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2233 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_right by 65 = 2234 + 0b1100_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 2235 + 0b0 Nativeint.shift_right by 66 = 2236 + 0b0 2237 + 0b1 Nativeint.shift_right by 66 = 2238 + 0b0 2239 + 0b101 Nativeint.shift_right by 66 = 2240 + 0b1 2241 + 0b111 Nativeint.shift_right by 66 = 2242 + 0b1 2243 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right by 66 = 2244 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2245 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_right by 66 = 2246 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2247 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right by 66 = 2248 + 0b1_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2249 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_right by 66 = 2250 + 0b1110_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 2251 + 0b0 Nativeint.shift_right by -1 = 2252 + 0b0 2253 + 0b1 Nativeint.shift_right by -1 = 2254 + 0b0 2255 + 0b101 Nativeint.shift_right by -1 = 2256 + 0b0 2257 + 0b111 Nativeint.shift_right by -1 = 2258 + 0b0 2259 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right by -1 = 2260 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2261 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_right by -1 = 2262 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2263 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right by -1 = 2264 + 0b0 2265 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_right by -1 = 2266 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2267 + 0b0 Nativeint.shift_right by -3 = 2268 + 0b0 2269 + 0b1 Nativeint.shift_right by -3 = 2270 + 0b0 2271 + 0b101 Nativeint.shift_right by -3 = 2272 + 0b0 2273 + 0b111 Nativeint.shift_right by -3 = 2274 + 0b0 2275 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right by -3 = 2276 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2277 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_right by -3 = 2278 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2279 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right by -3 = 2280 + 0b11 2281 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_right by -3 = 2282 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1100 2283 + 0b0 Nativeint.shift_right by 9_223_372_036_854_775_807 = 2284 + 0b0 2285 + 0b1 Nativeint.shift_right by 9_223_372_036_854_775_807 = 2286 + 0b0 2287 + 0b101 Nativeint.shift_right by 9_223_372_036_854_775_807 = 2288 + 0b0 2289 + 0b111 Nativeint.shift_right by 9_223_372_036_854_775_807 = 2290 + 0b0 2291 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right by 9_223_372_036_854_775_807 = 2292 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2293 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_right by 9_223_372_036_854_775_807 = 2294 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2295 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right by 9_223_372_036_854_775_807 = 2296 + 0b0 2297 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_right by 9_223_372_036_854_775_807 = 2298 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2299 + 0b0 Nativeint.shift_right by -9_223_372_036_854_775_808 = 2300 + 0b0 2301 + 0b1 Nativeint.shift_right by -9_223_372_036_854_775_808 = 2302 + 0b1 2303 + 0b101 Nativeint.shift_right by -9_223_372_036_854_775_808 = 2304 + 0b101 2305 + 0b111 Nativeint.shift_right by -9_223_372_036_854_775_808 = 2306 + 0b111 2307 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right by -9_223_372_036_854_775_808 = 2308 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2309 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_right by -9_223_372_036_854_775_808 = 2310 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 2311 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right by -9_223_372_036_854_775_808 = 2312 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2313 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_right by -9_223_372_036_854_775_808 = 2314 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 2315 + |}]; 2316 + () 2317 + ;; 2318 + 2319 + let%expect_test "shift_right_logical nativeint" = 2320 + test 2321 + ~op:I.Nativeint.shift_right_logical 2322 + ~expected_op:I.Nativeint.Naive.shift_right_logical 2323 + ~name:"Nativeint.shift_right_logical"; 2324 + [%expect 2325 + {| 2326 + 0b0 Nativeint.shift_right_logical by 0 = 2327 + 0b0 2328 + 0b1 Nativeint.shift_right_logical by 0 = 2329 + 0b1 2330 + 0b101 Nativeint.shift_right_logical by 0 = 2331 + 0b101 2332 + 0b111 Nativeint.shift_right_logical by 0 = 2333 + 0b111 2334 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right_logical by 0 = 2335 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2336 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_right_logical by 0 = 2337 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 2338 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right_logical by 0 = 2339 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2340 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_right_logical by 0 = 2341 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 2342 + 0b0 Nativeint.shift_right_logical by 1 = 2343 + 0b0 2344 + 0b1 Nativeint.shift_right_logical by 1 = 2345 + 0b0 2346 + 0b101 Nativeint.shift_right_logical by 1 = 2347 + 0b10 2348 + 0b111 Nativeint.shift_right_logical by 1 = 2349 + 0b11 2350 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right_logical by 1 = 2351 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2352 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_right_logical by 1 = 2353 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1110 2354 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right_logical by 1 = 2355 + 0b11_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2356 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_right_logical by 1 = 2357 + 0b100_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 2358 + 0b0 Nativeint.shift_right_logical by 2 = 2359 + 0b0 2360 + 0b1 Nativeint.shift_right_logical by 2 = 2361 + 0b0 2362 + 0b101 Nativeint.shift_right_logical by 2 = 2363 + 0b1 2364 + 0b111 Nativeint.shift_right_logical by 2 = 2365 + 0b1 2366 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right_logical by 2 = 2367 + 0b11_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2368 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_right_logical by 2 = 2369 + 0b11_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2370 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right_logical by 2 = 2371 + 0b1_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2372 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_right_logical by 2 = 2373 + 0b10_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 2374 + 0b0 Nativeint.shift_right_logical by 3 = 2375 + 0b0 2376 + 0b1 Nativeint.shift_right_logical by 3 = 2377 + 0b0 2378 + 0b101 Nativeint.shift_right_logical by 3 = 2379 + 0b0 2380 + 0b111 Nativeint.shift_right_logical by 3 = 2381 + 0b0 2382 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right_logical by 3 = 2383 + 0b1_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2384 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_right_logical by 3 = 2385 + 0b1_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2386 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right_logical by 3 = 2387 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2388 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_right_logical by 3 = 2389 + 0b1_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 2390 + 0b0 Nativeint.shift_right_logical by 4 = 2391 + 0b0 2392 + 0b1 Nativeint.shift_right_logical by 4 = 2393 + 0b0 2394 + 0b101 Nativeint.shift_right_logical by 4 = 2395 + 0b0 2396 + 0b111 Nativeint.shift_right_logical by 4 = 2397 + 0b0 2398 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right_logical by 4 = 2399 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2400 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_right_logical by 4 = 2401 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2402 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right_logical by 4 = 2403 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2404 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_right_logical by 4 = 2405 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 2406 + 0b0 Nativeint.shift_right_logical by 31 = 2407 + 0b0 2408 + 0b1 Nativeint.shift_right_logical by 31 = 2409 + 0b0 2410 + 0b101 Nativeint.shift_right_logical by 31 = 2411 + 0b0 2412 + 0b111 Nativeint.shift_right_logical by 31 = 2413 + 0b0 2414 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right_logical by 31 = 2415 + 0b1_1111_1111_1111_1111_1111_1111_1111_1111 2416 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_right_logical by 31 = 2417 + 0b1_1111_1111_1111_1111_1111_1111_1111_1111 2418 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right_logical by 31 = 2419 + 0b1111_1111_1111_1111_1111_1111_1111_1111 2420 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_right_logical by 31 = 2421 + 0b1_0000_0000_0000_0000_0000_0000_0000_0000 2422 + 0b0 Nativeint.shift_right_logical by 32 = 2423 + 0b0 2424 + 0b1 Nativeint.shift_right_logical by 32 = 2425 + 0b0 2426 + 0b101 Nativeint.shift_right_logical by 32 = 2427 + 0b0 2428 + 0b111 Nativeint.shift_right_logical by 32 = 2429 + 0b0 2430 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right_logical by 32 = 2431 + 0b1111_1111_1111_1111_1111_1111_1111_1111 2432 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_right_logical by 32 = 2433 + 0b1111_1111_1111_1111_1111_1111_1111_1111 2434 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right_logical by 32 = 2435 + 0b111_1111_1111_1111_1111_1111_1111_1111 2436 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_right_logical by 32 = 2437 + 0b1000_0000_0000_0000_0000_0000_0000_0000 2438 + 0b0 Nativeint.shift_right_logical by 33 = 2439 + 0b0 2440 + 0b1 Nativeint.shift_right_logical by 33 = 2441 + 0b0 2442 + 0b101 Nativeint.shift_right_logical by 33 = 2443 + 0b0 2444 + 0b111 Nativeint.shift_right_logical by 33 = 2445 + 0b0 2446 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right_logical by 33 = 2447 + 0b111_1111_1111_1111_1111_1111_1111_1111 2448 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_right_logical by 33 = 2449 + 0b111_1111_1111_1111_1111_1111_1111_1111 2450 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right_logical by 33 = 2451 + 0b11_1111_1111_1111_1111_1111_1111_1111 2452 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_right_logical by 33 = 2453 + 0b100_0000_0000_0000_0000_0000_0000_0000 2454 + 0b0 Nativeint.shift_right_logical by 62 = 2455 + 0b0 2456 + 0b1 Nativeint.shift_right_logical by 62 = 2457 + 0b0 2458 + 0b101 Nativeint.shift_right_logical by 62 = 2459 + 0b0 2460 + 0b111 Nativeint.shift_right_logical by 62 = 2461 + 0b0 2462 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right_logical by 62 = 2463 + 0b11 2464 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_right_logical by 62 = 2465 + 0b11 2466 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right_logical by 62 = 2467 + 0b1 2468 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_right_logical by 62 = 2469 + 0b10 2470 + 0b0 Nativeint.shift_right_logical by 63 = 2471 + 0b0 2472 + 0b1 Nativeint.shift_right_logical by 63 = 2473 + 0b0 2474 + 0b101 Nativeint.shift_right_logical by 63 = 2475 + 0b0 2476 + 0b111 Nativeint.shift_right_logical by 63 = 2477 + 0b0 2478 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right_logical by 63 = 2479 + 0b1 2480 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_right_logical by 63 = 2481 + 0b1 2482 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right_logical by 63 = 2483 + 0b0 2484 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_right_logical by 63 = 2485 + 0b1 2486 + 0b0 Nativeint.shift_right_logical by 64 = 2487 + 0b0 2488 + 0b1 Nativeint.shift_right_logical by 64 = 2489 + 0b1 2490 + 0b101 Nativeint.shift_right_logical by 64 = 2491 + 0b101 2492 + 0b111 Nativeint.shift_right_logical by 64 = 2493 + 0b111 2494 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right_logical by 64 = 2495 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2496 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_right_logical by 64 = 2497 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 2498 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right_logical by 64 = 2499 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2500 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_right_logical by 64 = 2501 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 2502 + 0b0 Nativeint.shift_right_logical by 65 = 2503 + 0b0 2504 + 0b1 Nativeint.shift_right_logical by 65 = 2505 + 0b0 2506 + 0b101 Nativeint.shift_right_logical by 65 = 2507 + 0b10 2508 + 0b111 Nativeint.shift_right_logical by 65 = 2509 + 0b11 2510 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right_logical by 65 = 2511 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2512 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_right_logical by 65 = 2513 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1110 2514 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right_logical by 65 = 2515 + 0b11_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2516 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_right_logical by 65 = 2517 + 0b100_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 2518 + 0b0 Nativeint.shift_right_logical by 66 = 2519 + 0b0 2520 + 0b1 Nativeint.shift_right_logical by 66 = 2521 + 0b0 2522 + 0b101 Nativeint.shift_right_logical by 66 = 2523 + 0b1 2524 + 0b111 Nativeint.shift_right_logical by 66 = 2525 + 0b1 2526 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right_logical by 66 = 2527 + 0b11_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2528 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_right_logical by 66 = 2529 + 0b11_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2530 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right_logical by 66 = 2531 + 0b1_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2532 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_right_logical by 66 = 2533 + 0b10_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 2534 + 0b0 Nativeint.shift_right_logical by -1 = 2535 + 0b0 2536 + 0b1 Nativeint.shift_right_logical by -1 = 2537 + 0b0 2538 + 0b101 Nativeint.shift_right_logical by -1 = 2539 + 0b0 2540 + 0b111 Nativeint.shift_right_logical by -1 = 2541 + 0b0 2542 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right_logical by -1 = 2543 + 0b1 2544 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_right_logical by -1 = 2545 + 0b1 2546 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right_logical by -1 = 2547 + 0b0 2548 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_right_logical by -1 = 2549 + 0b1 2550 + 0b0 Nativeint.shift_right_logical by -3 = 2551 + 0b0 2552 + 0b1 Nativeint.shift_right_logical by -3 = 2553 + 0b0 2554 + 0b101 Nativeint.shift_right_logical by -3 = 2555 + 0b0 2556 + 0b111 Nativeint.shift_right_logical by -3 = 2557 + 0b0 2558 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right_logical by -3 = 2559 + 0b111 2560 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_right_logical by -3 = 2561 + 0b111 2562 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right_logical by -3 = 2563 + 0b11 2564 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_right_logical by -3 = 2565 + 0b100 2566 + 0b0 Nativeint.shift_right_logical by 9_223_372_036_854_775_807 = 2567 + 0b0 2568 + 0b1 Nativeint.shift_right_logical by 9_223_372_036_854_775_807 = 2569 + 0b0 2570 + 0b101 Nativeint.shift_right_logical by 9_223_372_036_854_775_807 = 2571 + 0b0 2572 + 0b111 Nativeint.shift_right_logical by 9_223_372_036_854_775_807 = 2573 + 0b0 2574 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right_logical by 9_223_372_036_854_775_807 = 2575 + 0b1 2576 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_right_logical by 9_223_372_036_854_775_807 = 2577 + 0b1 2578 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right_logical by 9_223_372_036_854_775_807 = 2579 + 0b0 2580 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_right_logical by 9_223_372_036_854_775_807 = 2581 + 0b1 2582 + 0b0 Nativeint.shift_right_logical by -9_223_372_036_854_775_808 = 2583 + 0b0 2584 + 0b1 Nativeint.shift_right_logical by -9_223_372_036_854_775_808 = 2585 + 0b1 2586 + 0b101 Nativeint.shift_right_logical by -9_223_372_036_854_775_808 = 2587 + 0b101 2588 + 0b111 Nativeint.shift_right_logical by -9_223_372_036_854_775_808 = 2589 + 0b111 2590 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right_logical by -9_223_372_036_854_775_808 = 2591 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2592 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 Nativeint.shift_right_logical by -9_223_372_036_854_775_808 = 2593 + 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1101 2594 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 Nativeint.shift_right_logical by -9_223_372_036_854_775_808 = 2595 + 0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 2596 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 Nativeint.shift_right_logical by -9_223_372_036_854_775_808 = 2597 + 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 2598 + |}]; 2599 + () 2600 + ;; 2601 + end 2602 + 2603 + module%test [@tags "32-bits-only"] Nativeint_arch32 = struct 2604 + open Nativeint 2605 + 2606 + let numbers = List.map ~f:of_int_exn numbers @ [ max_value; min_value ] 2607 + let shifts = List.map ~f:of_int_exn shifts @ [ max_value; min_value ] 2608 + 2609 + let test ~op ~expected_op ~name = 2610 + let f ~shift x = 2611 + test_shifts (module Binary) (module Nativeint) ~op ~expected_op ~name x shift 2612 + in 2613 + List.iter shifts ~f:(fun shift -> 2614 + let f = f ~shift in 2615 + List.iter ~f numbers) 2616 + ;; 2617 + 2618 + let%expect_test "shift_left Nativeint arch32" = 2619 + test 2620 + ~op:I.Nativeint.shift_left 2621 + ~expected_op:I.Nativeint.Naive.shift_left 2622 + ~name:"Nativeint.shift_left"; 2623 + [%expect {| |}]; 2624 + () 2625 + ;; 2626 + 2627 + let%expect_test "shift_right Nativeint arch32" = 2628 + test 2629 + ~op:I.Nativeint.shift_right 2630 + ~expected_op:I.Nativeint.Naive.shift_right 2631 + ~name:"Nativeint.shift_right"; 2632 + [%expect {| |}]; 2633 + () 2634 + ;; 2635 + 2636 + let%expect_test "shift_right_logical Nativeint arch32" = 2637 + test 2638 + ~op:I.Nativeint.shift_right_logical 2639 + ~expected_op:I.Nativeint.Naive.shift_right_logical 2640 + ~name:"Nativeint.shift_right_logical"; 2641 + [%expect {| |}]; 2642 + () 2643 + ;; 2644 + end
+1
vendor/opam/ocaml_intrinsics_kernel/test/test_shifts.mli
··· 1 + (*_ This signature is deliberately empty. *)
vendor/opam/ocaml_intrinsics_kernel/test/test_stubs.js

This is a binary file and will not be displayed.

vendor/opam/ocaml_intrinsics_kernel/test/test_stubs.wat

This is a binary file and will not be displayed.