diff mbox

[v2,4/5] replace muldiv64(a, b, c) by (uint64_t)a * b / c

Message ID 1462800299-12641-5-git-send-email-lvivier@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Laurent Vivier May 9, 2016, 1:24 p.m. UTC
When "a" and "b" are 32bit values, we don't have to cast
them to 128bit, 64bit is enough.

This patch is the result of coccinelle script
scripts/coccinelle/simplify_muldiv64.cocci

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
 hw/audio/gus.c      | 2 +-
 hw/xtensa/pic_cpu.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

Comments

Max Filippov May 9, 2016, 2:43 p.m. UTC | #1
On Mon, May 9, 2016 at 4:24 PM, Laurent Vivier <lvivier@redhat.com> wrote:
> When "a" and "b" are 32bit values, we don't have to cast
> them to 128bit, 64bit is enough.
>
> This patch is the result of coccinelle script
> scripts/coccinelle/simplify_muldiv64.cocci
>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> ---
>  hw/audio/gus.c      | 2 +-
>  hw/xtensa/pic_cpu.c | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)

For xtensa PIC:
Acked-by: Max Filippov <jcmvbkbc@gmail.com>
diff mbox

Patch

diff --git a/hw/audio/gus.c b/hw/audio/gus.c
index 9dd6947..6c02646 100644
--- a/hw/audio/gus.c
+++ b/hw/audio/gus.c
@@ -144,7 +144,7 @@  static void GUS_callback (void *opaque, int free)
     s->left = samples;
 
  reset:
-    gus_irqgen (&s->emu, muldiv64 (net, 1000000, s->freq));
+    gus_irqgen (&s->emu, (uint64_t)net * 1000000 / s->freq);
 }
 
 int GUS_irqrequest (GUSEmuState *emu, int hwirq, int n)
diff --git a/hw/xtensa/pic_cpu.c b/hw/xtensa/pic_cpu.c
index c835bd0..343ea2c 100644
--- a/hw/xtensa/pic_cpu.c
+++ b/hw/xtensa/pic_cpu.c
@@ -121,8 +121,8 @@  void xtensa_rearm_ccompare_timer(CPUXtensaState *env)
     }
     env->wake_ccount = wake_ccount;
     timer_mod(env->ccompare_timer, env->halt_clock +
-            muldiv64(wake_ccount - env->sregs[CCOUNT],
-                1000000, env->config->clock_freq_khz));
+            (uint64_t)(wake_ccount - env->sregs[CCOUNT]) *
+            1000000 / env->config->clock_freq_khz);
 }
 
 static void xtensa_ccompare_cb(void *opaque)