aboutsummaryrefslogtreecommitdiffhomepage
path: root/kernel/nativevalues.ml
diff options
context:
space:
mode:
authorGravatar Maxime Dénès <mail@maximedenes.fr>2015-01-20 15:02:48 +0100
committerGravatar Maxime Dénès <mail@maximedenes.fr>2015-01-20 15:03:12 +0100
commit35fde66d67a7a4e36f04adc53347bbb87a34356e (patch)
treee2490f936f0fece2e59f4b6e1869d6b43c813f6f /kernel/nativevalues.ml
parentbef0d3bc629e25a281b4ed2424dc3b8405349acf (diff)
Fix a critical bug in machine arithmetic for native compiler.
Diffstat (limited to 'kernel/nativevalues.ml')
-rw-r--r--kernel/nativevalues.ml12
1 files changed, 11 insertions, 1 deletions
diff --git a/kernel/nativevalues.ml b/kernel/nativevalues.ml
index d7a219505..e4a779993 100644
--- a/kernel/nativevalues.ml
+++ b/kernel/nativevalues.ml
@@ -370,6 +370,11 @@ type coq_pair =
| Paccu of t
| PPair of t * t
+type coq_zn2z =
+ | Zaccu of t
+ | ZW0
+ | ZWW of t * t
+
let mkCarry b i =
if b then (Obj.magic (C1(of_uint i)):t)
else (Obj.magic (C0(of_uint i)):t)
@@ -413,8 +418,13 @@ let subcarryc accu x y =
let of_pair (x, y) =
(Obj.magic (PPair(of_uint x, of_uint y)):t)
+let zn2z_of_pair (x,y) =
+ if Uint31.equal x (Uint31.of_uint 0) &&
+ Uint31.equal y (Uint31.of_uint 0) then Obj.magic ZW0
+ else (Obj.magic (ZWW(of_uint x, of_uint y)) : t)
+
let no_check_mulc x y =
- of_pair(Uint31.mulc (to_uint x) (to_uint y))
+ zn2z_of_pair(Uint31.mulc (to_uint x) (to_uint y))
let mulc accu x y =
if is_int x && is_int y then no_check_mulc x y