* [Qemu-devel] [PATCH 2/3] Get rid of temporary variable cache.
@ 2009-06-29 17:49 Filip Navara
0 siblings, 0 replies; 3+ messages in thread
From: Filip Navara @ 2009-06-29 17:49 UTC (permalink / raw)
To: qemu-devel
The temporary variable cache actually hurts TCG more than it helps. Empirical results show that when running the Dhrystone benchmark with this patch improves the speed by about 2%.
---
target-arm/translate.c | 31 +++----------------------------
1 files changed, 3 insertions(+), 28 deletions(-)
diff --git a/target-arm/translate.c b/target-arm/translate.c
index 9a39536..2b8b770 100644
--- a/target-arm/translate.c
+++ b/target-arm/translate.c
@@ -111,44 +111,20 @@ void arm_translate_init(void)
#include "helpers.h"
}
-/* The code generator doesn't like lots of temporaries, so maintain our own
- cache for reuse within a function. */
-#define MAX_TEMPS 8
static int num_temps;
-static TCGv temps[MAX_TEMPS];
/* Allocate a temporary variable. */
static TCGv_i32 new_tmp(void)
{
- TCGv tmp;
- if (num_temps == MAX_TEMPS)
- abort();
-
- if (GET_TCGV_I32(temps[num_temps]))
- return temps[num_temps++];
-
- tmp = tcg_temp_new_i32();
- temps[num_temps++] = tmp;
- return tmp;
+ num_temps++;
+ return tcg_temp_new_i32();
}
/* Release a temporary variable. */
static void dead_tmp(TCGv tmp)
{
- int i;
+ tcg_temp_free(tmp);
num_temps--;
- i = num_temps;
- if (TCGV_EQUAL(temps[i], tmp))
- return;
-
- /* Shuffle this temp to the last slot. */
- while (!TCGV_EQUAL(temps[i], tmp))
- i--;
- while (i < num_temps) {
- temps[i] = temps[i + 1];
- i++;
- }
- temps[i] = tmp;
}
static inline TCGv load_cpu_offset(int offset)
@@ -8761,7 +8737,6 @@ static inline void gen_intermediate_code_internal(CPUState *env,
/* generate intermediate code */
num_temps = 0;
- memset(temps, 0, sizeof(temps));
pc_start = tb->pc;
--
1.6.3.msysgit.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH 2/3] Get rid of temporary variable cache.
@ 2009-06-29 18:34 Paul Brook
2009-06-29 18:57 ` Filip Navara
0 siblings, 1 reply; 3+ messages in thread
From: Paul Brook @ 2009-06-29 18:34 UTC (permalink / raw)
To: qemu-devel; +Cc: Filip Navara
On Monday 29 June 2009, Filip Navara wrote:
> The temporary variable cache actually hurts TCG more than it helps.
> Empirical results show that when running the Dhrystone benchmark with this
> patch improves the speed by about 2%.
I find it hard to believe this patch has any significant effect on runtime,
other than random variation. My guess is it spends almost all of its time in a
few guest loops, and no time doing translation. I'd expect the generated code
should be the same before and after.
I'm not saying this patch is a bad idea (new_tmp/dead_tmp predate
tcg_temp_free and are now redundant), just that I don't believe your benchmark
results.
Paul
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH 2/3] Get rid of temporary variable cache.
2009-06-29 18:34 Paul Brook
@ 2009-06-29 18:57 ` Filip Navara
0 siblings, 0 replies; 3+ messages in thread
From: Filip Navara @ 2009-06-29 18:57 UTC (permalink / raw)
To: Paul Brook; +Cc: qemu-devel
On Mon, Jun 29, 2009 at 8:34 PM, Paul Brook<paul@codesourcery.com> wrote:
> On Monday 29 June 2009, Filip Navara wrote:
>> The temporary variable cache actually hurts TCG more than it helps.
>> Empirical results show that when running the Dhrystone benchmark with this
>> patch improves the speed by about 2%.
>
> I find it hard to believe this patch has any significant effect on runtime,
> other than random variation. My guess is it spends almost all of its time in a
> few guest loops, and no time doing translation. I'd expect the generated code
> should be the same before and after.
You are right. That will teach me not to trust benchmarks and validate
the results by other means also.
> I'm not saying this patch is a bad idea (new_tmp/dead_tmp predate
> tcg_temp_free and are now redundant), just that I don't believe your benchmark
> results.
And you were right not to believe them. Thanks for looking at the patch.
Best regards,
Filip Navara
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-06-29 18:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-29 17:49 [Qemu-devel] [PATCH 2/3] Get rid of temporary variable cache Filip Navara
-- strict thread matches above, loose matches on Subject: below --
2009-06-29 18:34 Paul Brook
2009-06-29 18:57 ` Filip Navara
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).