qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: Aurelien Jarno <aurelien@aurel32.net>,
	Paolo Bonzini <pbonzini@redhat.com>
Cc: Leon Alrae <leon.alrae@imgtec.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] target-mips: apply workaround for TCG optimizations for MFC1
Date: Wed, 15 Jul 2015 11:02:22 +0100	[thread overview]
Message-ID: <55A62FAE.7030806@twiddle.net> (raw)
In-Reply-To: <20150715080633.GJ11361@aurel32.net>

[-- Attachment #1: Type: text/plain, Size: 889 bytes --]

On 07/15/2015 09:06 AM, Aurelien Jarno wrote:
> On 2015-07-15 09:31, Paolo Bonzini wrote:
>> Ok, I see your point.  If you put it like this :) the fault definitely
>> lies in the backends.  What I'm proposing would be in a new
>> tcg_reg_alloc_trunc function, and it would require implementing a
>> non-noop trunc.
>
> Why not reusing the existing trunc_shr_i64_i32 op? AFAIU, it has been
> designed exactly for that.

Indeed.

> Actually I think we should implement the following ops as optional but
> *real* TCG ops:
> - trunc_shr_i64_i32
> - extu_i32_i64
> - ext_i32_i64

While we could perhaps gain something from the last two, reliably using the 
first is probably the most important.

I've been unable to reproduce the binary in question.  I'm curious if something 
as simple as this helps.  Alternately, the two hunks might just cancel each 
other out and result in no change.


r~

[-- Attachment #2: z --]
[-- Type: text/plain, Size: 1793 bytes --]

diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c
index 45098c3..cc223c1 100644
--- a/tcg/tcg-op.c
+++ b/tcg/tcg-op.c
@@ -1751,17 +1751,17 @@ void tcg_gen_trunc_shr_i64_i32(TCGv_i32 ret, TCGv_i64 arg, unsigned count)
             tcg_gen_mov_i32(ret, TCGV_LOW(t));
             tcg_temp_free_i64(t);
         }
-    } else if (TCG_TARGET_HAS_trunc_shr_i32) {
-        tcg_gen_op3i_i32(INDEX_op_trunc_shr_i32, ret,
-                         MAKE_TCGV_I32(GET_TCGV_I64(arg)), count);
-    } else if (count == 0) {
-        tcg_gen_mov_i32(ret, MAKE_TCGV_I32(GET_TCGV_I64(arg)));
-    } else {
+        return;
+    }
+    if (!TCG_TARGET_HAS_trunc_shr_i32 && count != 0) {
         TCGv_i64 t = tcg_temp_new_i64();
         tcg_gen_shri_i64(t, arg, count);
-        tcg_gen_mov_i32(ret, MAKE_TCGV_I32(GET_TCGV_I64(t)));
         tcg_temp_free_i64(t);
+        arg = t;
+        count = 0;
     }
+    tcg_gen_op3i_i32(INDEX_op_trunc_shr_i32, ret,
+                     MAKE_TCGV_I32(GET_TCGV_I64(arg)), count);
 }
 
 void tcg_gen_extu_i32_i64(TCGv_i64 ret, TCGv_i32 arg)
diff --git a/tcg/tcg.c b/tcg/tcg.c
index 7e088b1..334d4c3 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -2374,6 +2374,13 @@ static inline int tcg_gen_code_common(TCGContext *s,
             tcg_reg_alloc_call(s, op->callo, op->calli, args,
                                dead_args, sync_args);
             break;
+        case INDEX_op_trunc_shr_i32:
+            if (!TCG_TARGET_HAS_trunc_shr_i32) {
+                tcg_assert(args[2] == 0);
+                tcg_reg_alloc_mov(s, def, args, dead_args, sync_args);
+                break;
+            }
+            /* FALLTHRU */
         default:
             /* Sanity check that we've not introduced any unhandled opcodes. */
             if (def->flags & TCG_OPF_NOT_PRESENT) {

  reply	other threads:[~2015-07-15 10:02 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-14 16:38 [Qemu-devel] [PATCH] target-mips: apply workaround for TCG optimizations for MFC1 Leon Alrae
2015-07-14 17:09 ` Aurelien Jarno
2015-07-14 18:20   ` Paolo Bonzini
2015-07-14 18:37     ` Aurelien Jarno
2015-07-14 20:56       ` Paolo Bonzini
2015-07-14 22:09         ` Aurelien Jarno
2015-07-15  7:31           ` Paolo Bonzini
2015-07-15  8:06             ` Aurelien Jarno
2015-07-15 10:02               ` Richard Henderson [this message]
2015-07-15 10:14                 ` Aurelien Jarno
2015-07-15 10:16                   ` Aurelien Jarno
2015-07-15 11:31                   ` Paolo Bonzini
2015-07-15  9:46 ` Richard Henderson
2015-07-15  9:59   ` Aurelien Jarno

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=55A62FAE.7030806@twiddle.net \
    --to=rth@twiddle.net \
    --cc=aurelien@aurel32.net \
    --cc=leon.alrae@imgtec.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).