[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC 05/14] tcg: Avoid loops against variable bounds
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [RFC 05/14] tcg: Avoid loops against variable bounds |
Date: |
Wed, 16 Nov 2016 20:51:41 +0100 |
Copy s->nb_globals or s->nb_temps to a local variable for the purposes
of iteration. This should allow the compiler to use low-overhead
looping constructs on some hosts.
Signed-off-by: Richard Henderson <address@hidden>
---
tcg/tcg.c | 27 ++++++++++-----------------
1 file changed, 10 insertions(+), 17 deletions(-)
diff --git a/tcg/tcg.c b/tcg/tcg.c
index b186b38..840c8b5 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -882,23 +882,16 @@ void tcg_gen_callN(TCGContext *s, void *func, TCGArg ret,
static void tcg_reg_alloc_start(TCGContext *s)
{
- int i;
+ int i, n;
TCGTemp *ts;
- for(i = 0; i < s->nb_globals; i++) {
+
+ for (i = 0, n = s->nb_globals; i < n; i++) {
ts = &s->temps[i];
- if (ts->fixed_reg) {
- ts->val_type = TEMP_VAL_REG;
- } else {
- ts->val_type = TEMP_VAL_MEM;
- }
+ ts->val_type = (ts->fixed_reg ? TEMP_VAL_REG : TEMP_VAL_MEM);
}
- for(i = s->nb_globals; i < s->nb_temps; i++) {
+ for (n = s->nb_temps; i < n; i++) {
ts = &s->temps[i];
- if (ts->temp_local) {
- ts->val_type = TEMP_VAL_MEM;
- } else {
- ts->val_type = TEMP_VAL_DEAD;
- }
+ ts->val_type = (ts->temp_local ? TEMP_VAL_MEM : TEMP_VAL_DEAD);
ts->mem_allocated = 0;
ts->fixed_reg = 0;
}
@@ -2046,9 +2039,9 @@ static void temp_save(TCGContext *s, TCGTemp *ts,
TCGRegSet allocated_regs)
temporary registers needs to be allocated to store a constant. */
static void save_globals(TCGContext *s, TCGRegSet allocated_regs)
{
- int i;
+ int i, n;
- for (i = 0; i < s->nb_globals; i++) {
+ for (i = 0, n = s->nb_globals; i < n; i++) {
temp_save(s, &s->temps[i], allocated_regs);
}
}
@@ -2058,9 +2051,9 @@ static void save_globals(TCGContext *s, TCGRegSet
allocated_regs)
temporary registers needs to be allocated to store a constant. */
static void sync_globals(TCGContext *s, TCGRegSet allocated_regs)
{
- int i;
+ int i, n;
- for (i = 0; i < s->nb_globals; i++) {
+ for (i = 0, n = s->nb_globals; i < n; i++) {
TCGTemp *ts = &s->temps[i];
tcg_debug_assert(ts->val_type != TEMP_VAL_REG
|| ts->fixed_reg
--
2.7.4
- [Qemu-devel] [RFC 00/14] tcg: Use TCGTemp pointers instead of indices, Richard Henderson, 2016/11/16
- [Qemu-devel] [RFC 01/14] tcg: Use NULL for TCGV_UNUSED_*, Richard Henderson, 2016/11/16
- [Qemu-devel] [RFC 04/14] tcg: Add temp_global bit to TCGTemp, Richard Henderson, 2016/11/16
- [Qemu-devel] [RFC 02/14] tcg: Define actual structures for TCGv_*, Richard Henderson, 2016/11/16
- [Qemu-devel] [RFC 05/14] tcg: Avoid loops against variable bounds,
Richard Henderson <=
- [Qemu-devel] [RFC 03/14] tcg: Use per-temp state data in liveness, Richard Henderson, 2016/11/16
- [Qemu-devel] [RFC 06/14] tcg: More use of arg_temp, Richard Henderson, 2016/11/16
- [Qemu-devel] [RFC 07/14] tcg: Change temp_allocate_frame arg to TCGTemp, Richard Henderson, 2016/11/16
- [Qemu-devel] [RFC 08/14] tcg: Remove unused TCG_CALL_DUMMY_TCGV, Richard Henderson, 2016/11/16
- [Qemu-devel] [RFC 09/14] tcg: More use of arg_index, Richard Henderson, 2016/11/16
- [Qemu-devel] [RFC 10/14] tcg: Map TCG_CALL_DUMMY_ARG to NULL, Richard Henderson, 2016/11/16
- [Qemu-devel] [RFC 13/14] tcg: Use temp number 0 again, Richard Henderson, 2016/11/16
- [Qemu-devel] [RFC 11/14] tcg: Introduce temp_info for the optimize pass, Richard Henderson, 2016/11/16
- [Qemu-devel] [RFC 12/14] tcg: Store pointers to temporaries directly in TCGArg, Richard Henderson, 2016/11/16
- [Qemu-devel] [RFC 14/14] tcg/optimize: Fold movcond 0/1 into setcond, Richard Henderson, 2016/11/16