From d2af79a77ed2936ff0ed90cadf8e48637d774d4c Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Tue, 4 Oct 2016 15:52:16 +0200 Subject: Turn 64-bit integer division and modulus by constants into multiply-high This trick was already implemented for 32-bit integer division and modulus. Here we extend it to the 64-bit case. For 32-bit target processors, the runtime library must implement 64-bit multiply-high (signed and unsigned). Tentative implementations are provided for IA32 and PowerPC, but need testing. --- common/Values.v | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'common/Values.v') diff --git a/common/Values.v b/common/Values.v index 88506bab..cfabb7a5 100644 --- a/common/Values.v +++ b/common/Values.v @@ -622,6 +622,18 @@ Definition mull' (v1 v2: val): val := | _, _ => Vundef end. +Definition mullhs (v1 v2: val): val := + match v1, v2 with + | Vlong n1, Vlong n2 => Vlong(Int64.mulhs n1 n2) + | _, _ => Vundef + end. + +Definition mullhu (v1 v2: val): val := + match v1, v2 with + | Vlong n1, Vlong n2 => Vlong(Int64.mulhu n1 n2) + | _, _ => Vundef + end. + Definition divls (v1 v2: val): option val := match v1, v2 with | Vlong n1, Vlong n2 => -- cgit