Merge "Change requested in launchpad bug #1288352" into 5.0
[packages/centos6/qemu.git] / 0018-tcg-optimize-split-expression-simplification.patch
1 From 16f29b266435c7eaffc5081c6bba4651d56a8ce8 Mon Sep 17 00:00:00 2001
2 From: Aurelien Jarno <aurelien@aurel32.net>
3 Date: Thu, 6 Sep 2012 16:47:13 +0200
4 Subject: [PATCH] tcg/optimize: split expression simplification
5
6 Split expression simplification in multiple parts so that a given op
7 can appear multiple times. This patch should not change anything.
8
9 Reviewed-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 | 14 +++++++++++++-
14  1 file changed, 13 insertions(+), 1 deletion(-)
15
16 diff --git a/tcg/optimize.c b/tcg/optimize.c
17 index 9c65474..63f970d 100644
18 --- a/tcg/optimize.c
19 +++ b/tcg/optimize.c
20 @@ -322,7 +322,7 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
21              break;
22          }
23  
24 -        /* Simplify expression if possible. */
25 +        /* Simplify expression for "op r, a, 0 => mov r, a" cases */
26          switch (op) {
27          CASE_OP_32_64(add):
28          CASE_OP_32_64(sub):
29 @@ -352,6 +352,12 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
30                  continue;
31              }
32              break;
33 +        default:
34 +            break;
35 +        }
36 +
37 +        /* Simplify expression for "op r, a, 0 => movi r, 0" cases */
38 +        switch (op) {
39          CASE_OP_32_64(mul):
40              if ((temps[args[2]].state == TCG_TEMP_CONST
41                  && temps[args[2]].val == 0)) {
42 @@ -362,6 +368,12 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
43                  continue;
44              }
45              break;
46 +        default:
47 +            break;
48 +        }
49 +
50 +        /* Simplify expression for "op r, a, a => mov r, a" cases */
51 +        switch (op) {
52          CASE_OP_32_64(or):
53          CASE_OP_32_64(and):
54              if (args[1] == args[2]) {
55 -- 
56 1.7.12.1
57