58 lines
2.0 KiB
Diff
58 lines
2.0 KiB
Diff
From af2bf6bcc6614622c87d28e9d763b57408c17500 Mon Sep 17 00:00:00 2001
|
|
From: Richard Henderson <rth@twiddle.net>
|
|
Date: Fri, 21 Sep 2012 10:13:38 -0700
|
|
Subject: [PATCH] tcg: Optimize two-address commutative operations
|
|
|
|
While swapping constants to the second operand, swap
|
|
sources matching destinations to the first operand.
|
|
|
|
Signed-off-by: Richard Henderson <rth@twiddle.net>
|
|
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
|
|
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
|
|
---
|
|
tcg/optimize.c | 15 ++++++++++++++-
|
|
1 file changed, 14 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/tcg/optimize.c b/tcg/optimize.c
|
|
index 26038a6..1be7631 100644
|
|
--- a/tcg/optimize.c
|
|
+++ b/tcg/optimize.c
|
|
@@ -334,6 +334,8 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
|
|
const TCGOpDef *def;
|
|
TCGArg *gen_args;
|
|
TCGArg tmp;
|
|
+ TCGCond cond;
|
|
+
|
|
/* Array VALS has an element for each temp.
|
|
If this temp holds a constant then its value is kept in VALS' element.
|
|
If this temp is a copy of other ones then this equivalence class'
|
|
@@ -395,13 +397,24 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
|
|
}
|
|
break;
|
|
CASE_OP_32_64(movcond):
|
|
+ cond = args[5];
|
|
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[5] = tcg_swap_cond(args[5]);
|
|
+ cond = tcg_swap_cond(cond);
|
|
+ }
|
|
+ /* For movcond, we canonicalize the "false" input reg to match
|
|
+ the destination reg so that the tcg backend can implement
|
|
+ a "move if true" operation. */
|
|
+ if (args[0] == args[3]) {
|
|
+ tmp = args[3];
|
|
+ args[3] = args[4];
|
|
+ args[4] = tmp;
|
|
+ cond = tcg_invert_cond(cond);
|
|
}
|
|
+ args[5] = cond;
|
|
default:
|
|
break;
|
|
}
|
|
--
|
|
1.7.12.1
|
|
|