aboutsummaryrefslogtreecommitdiff
path: root/tcg
diff options
context:
space:
mode:
authorAurelien Jarno <aurelien@aurel32.net>2012-09-06 16:47:14 +0200
committerAurelien Jarno <aurelien@aurel32.net>2012-09-11 18:05:59 +0200
commit65a7cce17ddf6fa1a30d4315da1631d9b6c8fd31 (patch)
tree3256ee3596c8d224aaa70e9616a0bb7e9f570164 /tcg
parent01ee5282ea955dee4e189b34ef888be6f36d9861 (diff)
tcg/optimize: swap brcond/setcond arguments when possible
brcond and setcond ops are not commutative, but it's easy to compute the new condition after swapping the arguments. Try to always put the constant argument in second position like for commutative ops, to help backends to generate better code. Reviewed-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Diffstat (limited to 'tcg')
-rw-r--r--tcg/optimize.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/tcg/optimize.c b/tcg/optimize.c
index 1698ba39b3..7debc8a36a 100644
--- a/tcg/optimize.c
+++ b/tcg/optimize.c
@@ -318,6 +318,24 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
args[2] = tmp;
}
break;
+ CASE_OP_32_64(brcond):
+ if (temps[args[0]].state == TCG_TEMP_CONST
+ && temps[args[1]].state != TCG_TEMP_CONST) {
+ tmp = args[0];
+ args[0] = args[1];
+ args[1] = tmp;
+ args[2] = tcg_swap_cond(args[2]);
+ }
+ break;
+ CASE_OP_32_64(setcond):
+ if (temps[args[1]].state == TCG_TEMP_CONST
+ && temps[args[2]].state != TCG_TEMP_CONST) {
+ tmp = args[1];
+ args[1] = args[2];
+ args[2] = tmp;
+ args[3] = tcg_swap_cond(args[3]);
+ }
+ break;
default:
break;
}