|
|
5544c1 |
From b7dc881b44c3698a0a81d226d6012d3c5833fd29 Mon Sep 17 00:00:00 2001
|
|
|
5544c1 |
From: Aurelien Jarno <aurelien@aurel32.net>
|
|
|
5544c1 |
Date: Fri, 7 Sep 2012 12:24:32 +0200
|
|
|
5544c1 |
Subject: [PATCH] tcg/optimize: fix if/else/break coding style
|
|
|
5544c1 |
|
|
|
5544c1 |
optimizer.c contains some cases were the break is appearing in both the
|
|
|
5544c1 |
if and the else parts. Fix that by moving it to the outer part. Also
|
|
|
5544c1 |
move some common code there.
|
|
|
5544c1 |
|
|
|
5544c1 |
Reviewed-by: Richard Henderson <rth@twiddle.net>
|
|
|
5544c1 |
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
|
|
|
5544c1 |
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
|
|
|
5544c1 |
---
|
|
|
5544c1 |
tcg/optimize.c | 34 +++++++++++-----------------------
|
|
|
5544c1 |
1 file changed, 11 insertions(+), 23 deletions(-)
|
|
|
5544c1 |
|
|
|
5544c1 |
diff --git a/tcg/optimize.c b/tcg/optimize.c
|
|
|
5544c1 |
index 156e8d9..fba0ed9 100644
|
|
|
5544c1 |
--- a/tcg/optimize.c
|
|
|
5544c1 |
+++ b/tcg/optimize.c
|
|
|
5544c1 |
@@ -441,15 +441,14 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
|
|
|
5544c1 |
if ((temps[args[0]].state == TCG_TEMP_COPY
|
|
|
5544c1 |
&& temps[args[0]].val == args[1])
|
|
|
5544c1 |
|| args[0] == args[1]) {
|
|
|
5544c1 |
- args += 3;
|
|
|
5544c1 |
gen_opc_buf[op_index] = INDEX_op_nop;
|
|
|
5544c1 |
} else {
|
|
|
5544c1 |
gen_opc_buf[op_index] = op_to_mov(op);
|
|
|
5544c1 |
tcg_opt_gen_mov(s, gen_args, args[0], args[1],
|
|
|
5544c1 |
nb_temps, nb_globals);
|
|
|
5544c1 |
gen_args += 2;
|
|
|
5544c1 |
- args += 3;
|
|
|
5544c1 |
}
|
|
|
5544c1 |
+ args += 3;
|
|
|
5544c1 |
continue;
|
|
|
5544c1 |
}
|
|
|
5544c1 |
break;
|
|
|
5544c1 |
@@ -480,15 +479,14 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
|
|
|
5544c1 |
CASE_OP_32_64(and):
|
|
|
5544c1 |
if (args[1] == args[2]) {
|
|
|
5544c1 |
if (args[1] == args[0]) {
|
|
|
5544c1 |
- args += 3;
|
|
|
5544c1 |
gen_opc_buf[op_index] = INDEX_op_nop;
|
|
|
5544c1 |
} else {
|
|
|
5544c1 |
gen_opc_buf[op_index] = op_to_mov(op);
|
|
|
5544c1 |
tcg_opt_gen_mov(s, gen_args, args[0], args[1], nb_temps,
|
|
|
5544c1 |
nb_globals);
|
|
|
5544c1 |
gen_args += 2;
|
|
|
5544c1 |
- args += 3;
|
|
|
5544c1 |
}
|
|
|
5544c1 |
+ args += 3;
|
|
|
5544c1 |
continue;
|
|
|
5544c1 |
}
|
|
|
5544c1 |
break;
|
|
|
5544c1 |
@@ -538,17 +536,14 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
|
|
|
5544c1 |
gen_opc_buf[op_index] = op_to_movi(op);
|
|
|
5544c1 |
tmp = do_constant_folding(op, temps[args[1]].val, 0);
|
|
|
5544c1 |
tcg_opt_gen_movi(gen_args, args[0], tmp, nb_temps, nb_globals);
|
|
|
5544c1 |
- gen_args += 2;
|
|
|
5544c1 |
- args += 2;
|
|
|
5544c1 |
- break;
|
|
|
5544c1 |
} else {
|
|
|
5544c1 |
reset_temp(args[0], nb_temps, nb_globals);
|
|
|
5544c1 |
gen_args[0] = args[0];
|
|
|
5544c1 |
gen_args[1] = args[1];
|
|
|
5544c1 |
- gen_args += 2;
|
|
|
5544c1 |
- args += 2;
|
|
|
5544c1 |
- break;
|
|
|
5544c1 |
}
|
|
|
5544c1 |
+ gen_args += 2;
|
|
|
5544c1 |
+ args += 2;
|
|
|
5544c1 |
+ break;
|
|
|
5544c1 |
CASE_OP_32_64(add):
|
|
|
5544c1 |
CASE_OP_32_64(sub):
|
|
|
5544c1 |
CASE_OP_32_64(mul):
|
|
|
5544c1 |
@@ -572,17 +567,15 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
|
|
|
5544c1 |
temps[args[2]].val);
|
|
|
5544c1 |
tcg_opt_gen_movi(gen_args, args[0], tmp, nb_temps, nb_globals);
|
|
|
5544c1 |
gen_args += 2;
|
|
|
5544c1 |
- args += 3;
|
|
|
5544c1 |
- break;
|
|
|
5544c1 |
} else {
|
|
|
5544c1 |
reset_temp(args[0], nb_temps, nb_globals);
|
|
|
5544c1 |
gen_args[0] = args[0];
|
|
|
5544c1 |
gen_args[1] = args[1];
|
|
|
5544c1 |
gen_args[2] = args[2];
|
|
|
5544c1 |
gen_args += 3;
|
|
|
5544c1 |
- args += 3;
|
|
|
5544c1 |
- break;
|
|
|
5544c1 |
}
|
|
|
5544c1 |
+ args += 3;
|
|
|
5544c1 |
+ break;
|
|
|
5544c1 |
CASE_OP_32_64(setcond):
|
|
|
5544c1 |
if (temps[args[1]].state == TCG_TEMP_CONST
|
|
|
5544c1 |
&& temps[args[2]].state == TCG_TEMP_CONST) {
|
|
|
5544c1 |
@@ -591,8 +584,6 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
|
|
|
5544c1 |
temps[args[2]].val, args[3]);
|
|
|
5544c1 |
tcg_opt_gen_movi(gen_args, args[0], tmp, nb_temps, nb_globals);
|
|
|
5544c1 |
gen_args += 2;
|
|
|
5544c1 |
- args += 4;
|
|
|
5544c1 |
- break;
|
|
|
5544c1 |
} else {
|
|
|
5544c1 |
reset_temp(args[0], nb_temps, nb_globals);
|
|
|
5544c1 |
gen_args[0] = args[0];
|
|
|
5544c1 |
@@ -600,9 +591,9 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
|
|
|
5544c1 |
gen_args[2] = args[2];
|
|
|
5544c1 |
gen_args[3] = args[3];
|
|
|
5544c1 |
gen_args += 4;
|
|
|
5544c1 |
- args += 4;
|
|
|
5544c1 |
- break;
|
|
|
5544c1 |
}
|
|
|
5544c1 |
+ args += 4;
|
|
|
5544c1 |
+ break;
|
|
|
5544c1 |
CASE_OP_32_64(brcond):
|
|
|
5544c1 |
if (temps[args[0]].state == TCG_TEMP_CONST
|
|
|
5544c1 |
&& temps[args[1]].state == TCG_TEMP_CONST) {
|
|
|
5544c1 |
@@ -612,12 +603,9 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
|
|
|
5544c1 |
gen_opc_buf[op_index] = INDEX_op_br;
|
|
|
5544c1 |
gen_args[0] = args[3];
|
|
|
5544c1 |
gen_args += 1;
|
|
|
5544c1 |
- args += 4;
|
|
|
5544c1 |
} else {
|
|
|
5544c1 |
gen_opc_buf[op_index] = INDEX_op_nop;
|
|
|
5544c1 |
- args += 4;
|
|
|
5544c1 |
}
|
|
|
5544c1 |
- break;
|
|
|
5544c1 |
} else {
|
|
|
5544c1 |
memset(temps, 0, nb_temps * sizeof(struct tcg_temp_info));
|
|
|
5544c1 |
reset_temp(args[0], nb_temps, nb_globals);
|
|
|
5544c1 |
@@ -626,9 +614,9 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
|
|
|
5544c1 |
gen_args[2] = args[2];
|
|
|
5544c1 |
gen_args[3] = args[3];
|
|
|
5544c1 |
gen_args += 4;
|
|
|
5544c1 |
- args += 4;
|
|
|
5544c1 |
- break;
|
|
|
5544c1 |
}
|
|
|
5544c1 |
+ args += 4;
|
|
|
5544c1 |
+ break;
|
|
|
5544c1 |
case INDEX_op_call:
|
|
|
5544c1 |
nb_call_args = (args[0] >> 16) + (args[0] & 0xffff);
|
|
|
5544c1 |
if (!(args[nb_call_args + 1] & (TCG_CALL_CONST | TCG_CALL_PURE))) {
|
|
|
5544c1 |
--
|
|
|
5544c1 |
1.7.12.1
|
|
|
5544c1 |
|