1 From af2bf6bcc6614622c87d28e9d763b57408c17500 Mon Sep 17 00:00:00 2001
2 From: Richard Henderson <rth@twiddle.net>
3 Date: Fri, 21 Sep 2012 10:13:38 -0700
4 Subject: [PATCH] tcg: Optimize two-address commutative operations
6 While swapping constants to the second operand, swap
7 sources matching destinations to the first operand.
9 Signed-off-by: Richard Henderson <rth@twiddle.net>
10 Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
13 tcg/optimize.c | 15 ++++++++++++++-
14 1 file changed, 14 insertions(+), 1 deletion(-)
16 diff --git a/tcg/optimize.c b/tcg/optimize.c
17 index 26038a6..1be7631 100644
20 @@ -334,6 +334,8 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
26 /* Array VALS has an element for each temp.
27 If this temp holds a constant then its value is kept in VALS' element.
28 If this temp is a copy of other ones then this equivalence class'
29 @@ -395,13 +397,24 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
32 CASE_OP_32_64(movcond):
34 if (temps[args[1]].state == TCG_TEMP_CONST
35 && temps[args[2]].state != TCG_TEMP_CONST) {
39 - args[5] = tcg_swap_cond(args[5]);
40 + cond = tcg_swap_cond(cond);
42 + /* For movcond, we canonicalize the "false" input reg to match
43 + the destination reg so that the tcg backend can implement
44 + a "move if true" operation. */
45 + if (args[0] == args[3]) {
49 + cond = tcg_invert_cond(cond);