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. --- test/regression/int64.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test/regression/int64.c') diff --git a/test/regression/int64.c b/test/regression/int64.c index 0012216f..d9785e95 100644 --- a/test/regression/int64.c +++ b/test/regression/int64.c @@ -56,6 +56,18 @@ static void test1(u64 x, u64 y) y3 = ((s64)y) >> 32; printf("x /s y3 = %llx\n", safe_sdiv64(x, y3)); printf("x %%s y3 = %llx\n", safe_smod64(x, y3)); + printf("x /u 3 = %llx\n", x / 3); + printf("x %%u 3 = %llx\n", x % 3); + printf("x /s 3 = %llx\n", (s64)x / 3); + printf("x %%s 3 = %llx\n", (s64)x % 3); + printf("x /u 5 = %llx\n", x / 5); + printf("x %%u 5 = %llx\n", x % 5); + printf("x /s 5 = %llx\n", (s64)x / 5); + printf("x %%s 5 = %llx\n", (s64)x % 5); + printf("x /u 11 = %llx\n", x / 11); + printf("x %%u 11 = %llx\n", x % 11); + printf("x /s 11 = %llx\n", (s64)x / 11); + printf("x %%s 11 = %llx\n", (s64)x % 11); printf("~x = %llx\n", ~x); printf("x & y = %llx\n", x & y); printf("x | y = %llx\n", x | y); -- cgit