Patchwork [v4,25/33] tcg-ppc64: Cleanup i32 constants to tcg_out_cmp

login
register
mail settings
Submitter Richard Henderson
Date April 4, 2013, 10:56 p.m.
Message ID <1365116186-19382-26-git-send-email-rth@twiddle.net>
Download mbox | patch
Permalink /patch/233980/
State New
Headers show

Comments

Richard Henderson - April 4, 2013, 10:56 p.m.
Nothing else in the call chain ensures that these
constants don't have garbage in the high bits.

Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 tcg/ppc64/tcg-target.c | 5 +++++
 1 file changed, 5 insertions(+)
Aurelien Jarno - April 15, 2013, 8:01 a.m.
On Thu, Apr 04, 2013 at 05:56:18PM -0500, Richard Henderson wrote:
> Nothing else in the call chain ensures that these
> constants don't have garbage in the high bits.
> 
> Signed-off-by: Richard Henderson <rth@twiddle.net>
> ---
>  tcg/ppc64/tcg-target.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/tcg/ppc64/tcg-target.c b/tcg/ppc64/tcg-target.c
> index edb2b6c..27d5ea5 100644
> --- a/tcg/ppc64/tcg-target.c
> +++ b/tcg/ppc64/tcg-target.c
> @@ -1059,6 +1059,11 @@ static void tcg_out_cmp (TCGContext *s, int cond, TCGArg arg1, TCGArg arg2,
>      int imm;
>      uint32_t op;
>  
> +    /* Simplify the comparisons below wrt CMPI.  */
> +    if (type == TCG_TYPE_I32) {
> +        arg2 = (int32_t)arg2;
> +    }
> +
>      switch (cond) {
>      case TCG_COND_EQ:
>      case TCG_COND_NE:

Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>

Patch

diff --git a/tcg/ppc64/tcg-target.c b/tcg/ppc64/tcg-target.c
index edb2b6c..27d5ea5 100644
--- a/tcg/ppc64/tcg-target.c
+++ b/tcg/ppc64/tcg-target.c
@@ -1059,6 +1059,11 @@  static void tcg_out_cmp (TCGContext *s, int cond, TCGArg arg1, TCGArg arg2,
     int imm;
     uint32_t op;
 
+    /* Simplify the comparisons below wrt CMPI.  */
+    if (type == TCG_TYPE_I32) {
+        arg2 = (int32_t)arg2;
+    }
+
     switch (cond) {
     case TCG_COND_EQ:
     case TCG_COND_NE: