All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aurelien Jarno <aurelien@aurel32.net>
To: Stefan Weil <sw@weilnetz.de>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] target-mips: Fix some helper functions (VR54xx multiplication)
Date: Fri, 24 Aug 2012 01:09:10 +0200	[thread overview]
Message-ID: <20120823230910.GI3553@ohm.aurel32.net> (raw)
In-Reply-To: <1330845699-12895-1-git-send-email-sw@weilnetz.de>

On Sun, Mar 04, 2012 at 08:21:39AM +0100, Stefan Weil wrote:
> Commits b5dc7732e1cc2fb549e48b7b5d664f2c79628e2e and
> be24bb4f3007c3e07cbf1934f7e781493d876ab7 optimized the code
> and removed the correct setting of t0. Fix this.
> 
> gcc-4.7 detected this bug because parameter arg1 was unused
> but set in set_HIT0_LO and set_HI_LOT0.
> 
> Cc: Aurelien Jarno <aurelien@aurel32.net>
> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> ---
> 
> Is anybody using QEMU with MIPS VR5432 code which uses the
> special multiply opcodes? I don't have such code, so I could
> not test my patch.
> 
> Regards,
> Stefan Weil

Thanks, applied.

>  target-mips/op_helper.c |   75 ++++++++++++++++++----------------------------
>  1 files changed, 29 insertions(+), 46 deletions(-)
> 
> diff --git a/target-mips/op_helper.c b/target-mips/op_helper.c
> index c51b9cb..8556c17 100644
> --- a/target-mips/op_helper.c
> +++ b/target-mips/op_helper.c
> @@ -199,115 +199,98 @@ static inline void set_HILO (uint64_t HILO)
>      env->active_tc.HI[0] = (int32_t)(HILO >> 32);
>  }
>  
> -static inline void set_HIT0_LO (target_ulong arg1, uint64_t HILO)
> +static inline target_ulong set_HIT0_LO(uint64_t HILO)
>  {
> +    target_ulong tmp;
>      env->active_tc.LO[0] = (int32_t)(HILO & 0xFFFFFFFF);
> -    arg1 = env->active_tc.HI[0] = (int32_t)(HILO >> 32);
> +    tmp = env->active_tc.HI[0] = (int32_t)(HILO >> 32);
> +    return tmp;
>  }
>  
> -static inline void set_HI_LOT0 (target_ulong arg1, uint64_t HILO)
> +static inline target_ulong set_HI_LOT0(uint64_t HILO)
>  {
> -    arg1 = env->active_tc.LO[0] = (int32_t)(HILO & 0xFFFFFFFF);
> +    target_ulong tmp = env->active_tc.LO[0] = (int32_t)(HILO & 0xFFFFFFFF);
>      env->active_tc.HI[0] = (int32_t)(HILO >> 32);
> +    return tmp;
>  }
>  
>  /* Multiplication variants of the vr54xx. */
>  target_ulong helper_muls (target_ulong arg1, target_ulong arg2)
>  {
> -    set_HI_LOT0(arg1, 0 - ((int64_t)(int32_t)arg1 * (int64_t)(int32_t)arg2));
> -
> -    return arg1;
> +    return set_HI_LOT0(0 - ((int64_t)(int32_t)arg1 * (int64_t)(int32_t)arg2));
>  }
>  
>  target_ulong helper_mulsu (target_ulong arg1, target_ulong arg2)
>  {
> -    set_HI_LOT0(arg1, 0 - ((uint64_t)(uint32_t)arg1 * (uint64_t)(uint32_t)arg2));
> -
> -    return arg1;
> +    return set_HI_LOT0(0 - (uint64_t)(uint32_t)arg1 * (uint64_t)(uint32_t)arg2);
>  }
>  
>  target_ulong helper_macc (target_ulong arg1, target_ulong arg2)
>  {
> -    set_HI_LOT0(arg1, ((int64_t)get_HILO()) + ((int64_t)(int32_t)arg1 * (int64_t)(int32_t)arg2));
> -
> -    return arg1;
> +    return set_HI_LOT0((int64_t)get_HILO() + (int64_t)(int32_t)arg1 *
> +                                             (int64_t)(int32_t)arg2);
>  }
>  
>  target_ulong helper_macchi (target_ulong arg1, target_ulong arg2)
>  {
> -    set_HIT0_LO(arg1, ((int64_t)get_HILO()) + ((int64_t)(int32_t)arg1 * (int64_t)(int32_t)arg2));
> -
> -    return arg1;
> +    return set_HIT0_LO((int64_t)get_HILO() + (int64_t)(int32_t)arg1 *
> +                                             (int64_t)(int32_t)arg2);
>  }
>  
>  target_ulong helper_maccu (target_ulong arg1, target_ulong arg2)
>  {
> -    set_HI_LOT0(arg1, ((uint64_t)get_HILO()) + ((uint64_t)(uint32_t)arg1 * (uint64_t)(uint32_t)arg2));
> -
> -    return arg1;
> +    return set_HI_LOT0((uint64_t)get_HILO() + (uint64_t)(uint32_t)arg1 *
> +                                              (uint64_t)(uint32_t)arg2);
>  }
>  
>  target_ulong helper_macchiu (target_ulong arg1, target_ulong arg2)
>  {
> -    set_HIT0_LO(arg1, ((uint64_t)get_HILO()) + ((uint64_t)(uint32_t)arg1 * (uint64_t)(uint32_t)arg2));
> -
> -    return arg1;
> +    return set_HIT0_LO((uint64_t)get_HILO() + (uint64_t)(uint32_t)arg1 *
> +                                              (uint64_t)(uint32_t)arg2);
>  }
>  
>  target_ulong helper_msac (target_ulong arg1, target_ulong arg2)
>  {
> -    set_HI_LOT0(arg1, ((int64_t)get_HILO()) - ((int64_t)(int32_t)arg1 * (int64_t)(int32_t)arg2));
> -
> -    return arg1;
> +    return set_HI_LOT0((int64_t)get_HILO() - (int64_t)(int32_t)arg1 *
> +                                             (int64_t)(int32_t)arg2);
>  }
>  
>  target_ulong helper_msachi (target_ulong arg1, target_ulong arg2)
>  {
> -    set_HIT0_LO(arg1, ((int64_t)get_HILO()) - ((int64_t)(int32_t)arg1 * (int64_t)(int32_t)arg2));
> -
> -    return arg1;
> +    return set_HIT0_LO((int64_t)get_HILO() - (int64_t)(int32_t)arg1 *
> +                                             (int64_t)(int32_t)arg2);
>  }
>  
>  target_ulong helper_msacu (target_ulong arg1, target_ulong arg2)
>  {
> -    set_HI_LOT0(arg1, ((uint64_t)get_HILO()) - ((uint64_t)(uint32_t)arg1 * (uint64_t)(uint32_t)arg2));
> -
> -    return arg1;
> +    return set_HI_LOT0((uint64_t)get_HILO() - (uint64_t)(uint32_t)arg1 *
> +                                              (uint64_t)(uint32_t)arg2);
>  }
>  
>  target_ulong helper_msachiu (target_ulong arg1, target_ulong arg2)
>  {
> -    set_HIT0_LO(arg1, ((uint64_t)get_HILO()) - ((uint64_t)(uint32_t)arg1 * (uint64_t)(uint32_t)arg2));
> -
> -    return arg1;
> +    return set_HIT0_LO((uint64_t)get_HILO() - (uint64_t)(uint32_t)arg1 *
> +                                              (uint64_t)(uint32_t)arg2);
>  }
>  
>  target_ulong helper_mulhi (target_ulong arg1, target_ulong arg2)
>  {
> -    set_HIT0_LO(arg1, (int64_t)(int32_t)arg1 * (int64_t)(int32_t)arg2);
> -
> -    return arg1;
> +    return set_HIT0_LO((int64_t)(int32_t)arg1 * (int64_t)(int32_t)arg2);
>  }
>  
>  target_ulong helper_mulhiu (target_ulong arg1, target_ulong arg2)
>  {
> -    set_HIT0_LO(arg1, (uint64_t)(uint32_t)arg1 * (uint64_t)(uint32_t)arg2);
> -
> -    return arg1;
> +    return set_HIT0_LO((uint64_t)(uint32_t)arg1 * (uint64_t)(uint32_t)arg2);
>  }
>  
>  target_ulong helper_mulshi (target_ulong arg1, target_ulong arg2)
>  {
> -    set_HIT0_LO(arg1, 0 - ((int64_t)(int32_t)arg1 * (int64_t)(int32_t)arg2));
> -
> -    return arg1;
> +    return set_HIT0_LO(0 - (int64_t)(int32_t)arg1 * (int64_t)(int32_t)arg2);
>  }
>  
>  target_ulong helper_mulshiu (target_ulong arg1, target_ulong arg2)
>  {
> -    set_HIT0_LO(arg1, 0 - ((uint64_t)(uint32_t)arg1 * (uint64_t)(uint32_t)arg2));
> -
> -    return arg1;
> +    return set_HIT0_LO(0 - (uint64_t)(uint32_t)arg1 * (uint64_t)(uint32_t)arg2);
>  }
>  
>  #ifdef TARGET_MIPS64
> -- 
> 1.7.9
> 
> 
> 

-- 
Aurelien Jarno                          GPG: 1024D/F1BCDB73
aurelien@aurel32.net                 http://www.aurel32.net

      parent reply	other threads:[~2012-08-23 23:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-04  7:21 [Qemu-devel] [PATCH] target-mips: Fix some helper functions (VR54xx multiplication) Stefan Weil
2012-08-23 20:40 ` Stefan Weil
2012-08-23 23:09 ` Aurelien Jarno [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120823230910.GI3553@ohm.aurel32.net \
    --to=aurelien@aurel32.net \
    --cc=qemu-devel@nongnu.org \
    --cc=sw@weilnetz.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.