All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
To: Richard Henderson <rth@twiddle.net>
Cc: qemu-devel@nongnu.org, aurelien@aurel32.net, agraf@suse.de
Subject: Re: [Qemu-devel] [PATCH 5/7] tcg-i386: Implement deposit operation.
Date: Tue, 25 Jan 2011 13:27:49 +0100	[thread overview]
Message-ID: <20110125122749.GA19736@edde.se.axis.com> (raw)
In-Reply-To: <1294716228-9299-6-git-send-email-rth@twiddle.net>

On Mon, Jan 10, 2011 at 07:23:46PM -0800, Richard Henderson wrote:
> Special case deposits that are implementable with byte and word stores.
> Otherwise implement with double-word shift plus rotates.
> 
> Expose tcg_scratch_alloc to the backend for allocation of scratch registers.
> 
> Signed-off-by: Richard Henderson <rth@twiddle.net>

Hi,

I've tested this patch a bit and got mixed results. I tested with patched
CRIS and MicroBlaze translators. The patch works OK (it doesn't break
anything) for the usecases I had but I saw a bit of a slowdown with
MicroBlaze (compare to not using deposit at all).

I suspect that the fast 8 and 16 bit x86 deposits are giving me a slight
speedup with CRIS. But MicroBlaze uses one bit fields into bit 2 and
31. Those seem to be slower with deposit than with other tcg sequences.

I would have guessed that at worst, this patch would be equally fast
as any TCG sequence. Am I missing something?

These are the patches I've applied:

Microblaze translator:
diff --git a/target-microblaze/translate.c b/target-microblaze/translate.c
index 2207431..39ab3a5 100644
--- a/target-microblaze/translate.c
+++ b/target-microblaze/translate.c
@@ -160,6 +160,7 @@ static void read_carry(DisasContext *dc, TCGv d)
 
 static void write_carry(DisasContext *dc, TCGv v)
 {
+#if 0
     TCGv t0 = tcg_temp_new();
     tcg_gen_shli_tl(t0, v, 31);
     tcg_gen_sari_tl(t0, t0, 31);
@@ -168,6 +169,10 @@ static void write_carry(DisasContext *dc, TCGv v)
                     ~(MSR_C | MSR_CC));
     tcg_gen_or_tl(cpu_SR[SR_MSR], cpu_SR[SR_MSR], t0);
     tcg_temp_free(t0);
+#else
+    tcg_gen_deposit_tl(cpu_SR[SR_MSR], cpu_SR[SR_MSR], v, 2, 1);
+    tcg_gen_deposit_tl(cpu_SR[SR_MSR], cpu_SR[SR_MSR], v, 31, 1);
+#endif
 }


CRIS translator:
commit 9f427e14b2535a067bf046fea093f28cfaa92f7f
Author: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Date:   Fri Jan 21 22:09:44 2011 +0100

    cris: Use deposit for ALU writeback
    
    Most ALU insns on CRIS have deposit semantics in the writeback
    stage. Use the new deposit tcg operation to perform the write
    back to registers.
    
    Move the extract of the result into cc_result to the slow path
    in evaluate_flags.
    
    Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>

diff --git a/target-cris/translate.c b/target-cris/translate.c
index f4cc125..018ce68 100644
--- a/target-cris/translate.c
+++ b/target-cris/translate.c
@@ -861,11 +861,6 @@ static void cris_alu_op_exec(DisasContext *dc, int op,
 			BUG();
 			break;
 	}
-
-	if (size == 1)
-		tcg_gen_andi_tl(dst, dst, 0xff);
-	else if (size == 2)
-		tcg_gen_andi_tl(dst, dst, 0xffff);
 }
 
 static void cris_alu(DisasContext *dc, int op,
@@ -880,6 +875,7 @@ static void cris_alu(DisasContext *dc, int op,
 		tmp = tcg_temp_new();
 		writeback = 0;
 	} else if (size == 4) {
+		/* We write directly into the dest.  */
 		tmp = d;
 		writeback = 0;
 	} else
@@ -892,11 +888,7 @@ static void cris_alu(DisasContext *dc, int op,
 
 	/* Writeback.  */
 	if (writeback) {
-		if (size == 1)
-			tcg_gen_andi_tl(d, d, ~0xff);
-		else
-			tcg_gen_andi_tl(d, d, ~0xffff);
-		tcg_gen_or_tl(d, d, tmp);
+		tcg_gen_deposit_tl(d, d, tmp, 0, size * 8);
 	}
 	if (!TCGV_EQUAL(tmp, d))
 		tcg_temp_free(tmp);
@@ -941,6 +933,10 @@ static void gen_tst_cc (DisasContext *dc, TCGv cc, int cond)
 	 * When this function is done, T0 should be non-zero if the condition
 	 * code is true.
 	 */
+	if (dc->cc_size != 4) {
+		tcg_gen_andi_tl(cc_result, cc_result,
+				(1 << (dc->cc_size * 8)) - 1);
+	}
 	arith_opt = arith_cc(dc) && !dc->flags_uptodate;
 	move_opt = (dc->cc_op == CC_OP_MOVE);
 	switch (cond) {

  reply	other threads:[~2011-01-25 12:48 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-11  3:23 [Qemu-devel] [PATCH 0/7] Define "deposit" tcg operation, v2 Richard Henderson
2011-01-11  3:23 ` [Qemu-devel] [PATCH 1/7] tcg: Define "deposit" as an optional operation Richard Henderson
2011-01-11 23:45   ` Aurelien Jarno
2011-01-12 11:00   ` Edgar E. Iglesias
2011-01-11  3:23 ` [Qemu-devel] [PATCH 2/7] tcg-ppc: Implement deposit operation Richard Henderson
2011-01-11 12:40   ` [Qemu-devel] " malc
2011-01-11 16:32     ` Richard Henderson
2011-01-11 19:11       ` malc
2011-01-11  3:23 ` [Qemu-devel] [PATCH 3/7] tcg-hppa: " Richard Henderson
2011-01-11  3:23 ` [Qemu-devel] [PATCH 4/7] tcg-ia64: " Richard Henderson
2011-01-11  3:23 ` [Qemu-devel] [PATCH 5/7] tcg-i386: " Richard Henderson
2011-01-25 12:27   ` Edgar E. Iglesias [this message]
2011-01-25 16:13     ` Richard Henderson
2011-01-25 16:48       ` Edgar E. Iglesias
2011-01-25 22:07         ` Richard Henderson
2011-01-26  8:53           ` Edgar E. Iglesias
2011-01-26  9:23             ` Alexander Graf
2011-01-26 15:50               ` Richard Henderson
2011-01-26 16:00                 ` Alexander Graf
2011-01-26 16:34                   ` Avi Kivity
2011-01-26 16:40                   ` Richard Henderson
2011-01-26 16:50                     ` Alexander Graf
2011-01-26 18:21                       ` Richard Henderson
2011-01-26 18:27                         ` Alexander Graf
2011-01-26 18:55                           ` Richard Henderson
2011-01-26 19:01                             ` Alexander Graf
2011-01-26 19:05                               ` Richard Henderson
2011-01-26 19:09                                 ` Alexander Graf
2011-01-26 19:19                                   ` Richard Henderson
2011-01-26 19:27                                     ` Alexander Graf
2011-01-31  8:33     ` Aurelien Jarno
2011-02-08 18:05       ` Richard Henderson
2011-02-09  7:41         ` [Qemu-devel] " Paolo Bonzini
2011-02-09 17:24           ` Blue Swirl
2011-01-11  3:23 ` [Qemu-devel] [PATCH 6/7] target-i386: Use " Richard Henderson
2011-01-12 11:01   ` Edgar E. Iglesias
2011-01-20 11:06   ` Aurelien Jarno
2011-01-11  3:23 ` [Qemu-devel] [PATCH 7/7] target-ppc: " Richard Henderson
2011-01-11 23:45 ` [Qemu-devel] [PATCH 0/7] Define "deposit" tcg operation, v2 Aurelien Jarno
2011-01-20 11:31 ` Edgar E. Iglesias
  -- strict thread matches above, loose matches on Subject: below --
2011-01-07 22:42 [Qemu-devel] [PATCH 0/7] Define "deposit" tcg operation Richard Henderson
2011-01-07 22:43 ` [Qemu-devel] [PATCH 5/7] tcg-i386: Implement deposit operation Richard Henderson

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=20110125122749.GA19736@edde.se.axis.com \
    --to=edgar.iglesias@gmail.com \
    --cc=agraf@suse.de \
    --cc=aurelien@aurel32.net \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /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.