Re: [Qemu-devel] [PATCH 2/2] qemu-common.h: optimise muldiv64 for x86_64 architecture

2015-01-09 Thread Frediano Ziglio
2015-01-09 12:22 GMT+00:00 Peter Maydell peter.mayd...@linaro.org: On 9 January 2015 at 11:25, Frediano Ziglio fredd...@gmail.com wrote: As this platform can do multiply/divide using 128 bit precision use these instructions to implement it. Signed-off-by: Frediano Ziglio

Re: [Qemu-devel] [PATCH 2/2] qemu-common.h: optimise muldiv64 for x86_64 architecture

2015-01-09 Thread Peter Maydell
On 9 January 2015 at 16:08, Frediano Ziglio fredd...@gmail.com wrote: I agree (after some digging) we are not sure we won't get that overflow. Agree to drop the second patch. However I would retain the first. Compiler can use it to optimize much easier. For instance if compiler understand that

Re: [Qemu-devel] [PATCH 2/2] qemu-common.h: optimise muldiv64 for x86_64 architecture

2015-01-09 Thread Peter Maydell
On 9 January 2015 at 15:41, Frediano Ziglio fredd...@gmail.com wrote: 2015-01-09 12:22 GMT+00:00 Peter Maydell peter.mayd...@linaro.org: +/* Optimised x64 version. This assume that a*b/c fits in 64 bit */ This assumption isn't necessarily true, and this implementation will dump core on

Re: [Qemu-devel] [PATCH 2/2] qemu-common.h: optimise muldiv64 for x86_64 architecture

2015-01-09 Thread Frediano Ziglio
2015-01-09 15:52 GMT+00:00 Peter Maydell peter.mayd...@linaro.org: On 9 January 2015 at 15:41, Frediano Ziglio fredd...@gmail.com wrote: 2015-01-09 12:22 GMT+00:00 Peter Maydell peter.mayd...@linaro.org: +/* Optimised x64 version. This assume that a*b/c fits in 64 bit */ This assumption isn't

Re: [Qemu-devel] [PATCH 2/2] qemu-common.h: optimise muldiv64 for x86_64 architecture

2015-01-09 Thread Frediano Ziglio
2015-01-09 11:43 GMT+00:00 Paolo Bonzini pbonz...@redhat.com: On 09/01/2015 12:25, Frediano Ziglio wrote: /* compute with 96 bit intermediate result: (a*b)/c */ -#ifdef CONFIG_INT128 +#if defined(CONFIG_INT128) !defined(__x86_64__) static inline uint64_t muldiv64(uint64_t a, uint32_t b,

Re: [Qemu-devel] [PATCH 2/2] qemu-common.h: optimise muldiv64 for x86_64 architecture

2015-01-09 Thread Peter Maydell
On 9 January 2015 at 11:25, Frediano Ziglio fredd...@gmail.com wrote: As this platform can do multiply/divide using 128 bit precision use these instructions to implement it. Signed-off-by: Frediano Ziglio frediano.zig...@huawei.com --- include/qemu-common.h | 14 +- 1 file

[Qemu-devel] [PATCH 2/2] qemu-common.h: optimise muldiv64 for x86_64 architecture

2015-01-09 Thread Frediano Ziglio
As this platform can do multiply/divide using 128 bit precision use these instructions to implement it. Signed-off-by: Frediano Ziglio frediano.zig...@huawei.com --- include/qemu-common.h | 14 +- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/include/qemu-common.h

Re: [Qemu-devel] [PATCH 2/2] qemu-common.h: optimise muldiv64 for x86_64 architecture

2015-01-09 Thread Paolo Bonzini
On 09/01/2015 12:25, Frediano Ziglio wrote: /* compute with 96 bit intermediate result: (a*b)/c */ -#ifdef CONFIG_INT128 +#if defined(CONFIG_INT128) !defined(__x86_64__) static inline uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c) { return (__int128)a * b / c; } +#elif