|
|
5544c1 |
From 1127ad0d084f0cef11b5658b3dbbf8505d8d3af0 Mon Sep 17 00:00:00 2001
|
|
|
5544c1 |
From: Aurelien Jarno <aurelien@aurel32.net>
|
|
|
5544c1 |
Date: Thu, 6 Sep 2012 16:47:14 +0200
|
|
|
5544c1 |
Subject: [PATCH] tcg/optimize: swap brcond/setcond arguments when possible
|
|
|
5544c1 |
|
|
|
5544c1 |
brcond and setcond ops are not commutative, but it's easy to compute the
|
|
|
5544c1 |
new condition after swapping the arguments. Try to always put the constant
|
|
|
5544c1 |
argument in second position like for commutative ops, to help backends to
|
|
|
5544c1 |
generate better code.
|
|
|
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 | 18 ++++++++++++++++++
|
|
|
5544c1 |
1 file changed, 18 insertions(+)
|
|
|
5544c1 |
|
|
|
5544c1 |
diff --git a/tcg/optimize.c b/tcg/optimize.c
|
|
|
5544c1 |
index 1698ba3..7debc8a 100644
|
|
|
5544c1 |
--- a/tcg/optimize.c
|
|
|
5544c1 |
+++ b/tcg/optimize.c
|
|
|
5544c1 |
@@ -318,6 +318,24 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
|
|
|
5544c1 |
args[2] = tmp;
|
|
|
5544c1 |
}
|
|
|
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 |
+ tmp = args[0];
|
|
|
5544c1 |
+ args[0] = args[1];
|
|
|
5544c1 |
+ args[1] = tmp;
|
|
|
5544c1 |
+ args[2] = tcg_swap_cond(args[2]);
|
|
|
5544c1 |
+ }
|
|
|
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 |
+ tmp = args[1];
|
|
|
5544c1 |
+ args[1] = args[2];
|
|
|
5544c1 |
+ args[2] = tmp;
|
|
|
5544c1 |
+ args[3] = tcg_swap_cond(args[3]);
|
|
|
5544c1 |
+ }
|
|
|
5544c1 |
+ break;
|
|
|
5544c1 |
default:
|
|
|
5544c1 |
break;
|
|
|
5544c1 |
}
|
|
|
5544c1 |
--
|
|
|
5544c1 |
1.7.12.1
|
|
|
5544c1 |
|