[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 10/51] tcg: Avoid loops against variable bounds
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PULL 10/51] tcg: Avoid loops against variable bounds |
Date: |
Wed, 25 Oct 2017 11:34:54 +0200 |
From: Richard Henderson <address@hidden>
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.
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Reviewed-by: Emilio G. Cota <address@hidden>
Reviewed-by: Alex Bennée <address@hidden>
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 d08e34a9d8..840e65c0d4 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -1159,23 +1159,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;
}
@@ -2277,9 +2270,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);
}
}
@@ -2289,9 +2282,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.13.6
- [Qemu-devel] [PULL 01/51] tcg: Merge opcode arguments into TCGOp, (continued)
- [Qemu-devel] [PULL 01/51] tcg: Merge opcode arguments into TCGOp, Richard Henderson, 2017/10/25
- [Qemu-devel] [PULL 03/51] tcg: Propagate args to op->args in tcg.c, Richard Henderson, 2017/10/25
- [Qemu-devel] [PULL 06/51] tcg: Add temp_global bit to TCGTemp, Richard Henderson, 2017/10/25
- [Qemu-devel] [PULL 04/51] tcg: Propagate TCGOp down to allocators, Richard Henderson, 2017/10/25
- [Qemu-devel] [PULL 05/51] tcg: Introduce arg_temp, Richard Henderson, 2017/10/25
- [Qemu-devel] [PULL 02/51] tcg: Propagate args to op->args in optimizer, Richard Henderson, 2017/10/25
- [Qemu-devel] [PULL 07/51] tcg: Return NULL temp for TCG_CALL_DUMMY_ARG, Richard Henderson, 2017/10/25
- [Qemu-devel] [PULL 08/51] tcg: Introduce temp_arg, export temp_idx, Richard Henderson, 2017/10/25
- [Qemu-devel] [PULL 11/51] tcg: Change temp_allocate_frame arg to TCGTemp, Richard Henderson, 2017/10/25
- [Qemu-devel] [PULL 09/51] tcg: Use per-temp state data in liveness, Richard Henderson, 2017/10/25
- [Qemu-devel] [PULL 10/51] tcg: Avoid loops against variable bounds,
Richard Henderson <=
- [Qemu-devel] [PULL 12/51] tcg: Remove unused TCG_CALL_DUMMY_TCGV, Richard Henderson, 2017/10/25
- [Qemu-devel] [PULL 15/51] tcg: Push tcg_ctx into tcg_gen_callN, Richard Henderson, 2017/10/25
- [Qemu-devel] [PULL 14/51] tcg: Push tcg_ctx into generator functions, Richard Henderson, 2017/10/25
- [Qemu-devel] [PULL 13/51] tcg: Use per-temp state data in optimize, Richard Henderson, 2017/10/25
- [Qemu-devel] [PULL 18/51] tcg: Remove GET_TCGV_* and MAKE_TCGV_*, Richard Henderson, 2017/10/25
- [Qemu-devel] [PULL 21/51] tcg: Use offsets not indices for TCGv_*, Richard Henderson, 2017/10/25
- [Qemu-devel] [PULL 17/51] tcg: Introduce temp_tcgv_{i32,i64,ptr}, Richard Henderson, 2017/10/25
- [Qemu-devel] [PULL 24/51] tcg: Include CF_COUNT_MASK in CF_HASH_MASK, Richard Henderson, 2017/10/25
- [Qemu-devel] [PULL 16/51] tcg: Introduce tcgv_{i32, i64, ptr}_{arg, temp}, Richard Henderson, 2017/10/25
- [Qemu-devel] [PULL 23/51] tcg: Add CPUState cflags_next_tb, Richard Henderson, 2017/10/25