Initial commit with version 1.2.0-24
[packages/centos6/qemu.git] / 0053-tcg-Optimize-two-address-commutative-operations.patch
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
5
6 While swapping constants to the second operand, swap
7 sources matching destinations to the first operand.
8
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>
12 ---
13  tcg/optimize.c | 15 ++++++++++++++-
14  1 file changed, 14 insertions(+), 1 deletion(-)
15
16 diff --git a/tcg/optimize.c b/tcg/optimize.c
17 index 26038a6..1be7631 100644
18 --- a/tcg/optimize.c
19 +++ b/tcg/optimize.c
20 @@ -334,6 +334,8 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
21      const TCGOpDef *def;
22      TCGArg *gen_args;
23      TCGArg tmp;
24 +    TCGCond cond;
25 +
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,
30              }
31              break;
32          CASE_OP_32_64(movcond):
33 +            cond = args[5];
34              if (temps[args[1]].state == TCG_TEMP_CONST
35                  && temps[args[2]].state != TCG_TEMP_CONST) {
36                  tmp = args[1];
37                  args[1] = args[2];
38                  args[2] = tmp;
39 -                args[5] = tcg_swap_cond(args[5]);
40 +                cond = tcg_swap_cond(cond);
41 +            }
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]) {
46 +                tmp = args[3];
47 +                args[3] = args[4];
48 +                args[4] = tmp;
49 +                cond = tcg_invert_cond(cond);
50              }
51 +            args[5] = cond;
52          default:
53              break;
54          }
55 -- 
56 1.7.12.1
57