Initial commit with version 1.2.0-24
[packages/centos6/qemu.git] / 0075-tcg-optimize-prefer-the-op-a-a-b-form-for-commutativ.patch
1 From a0b71ad6a3f8aeb8b5ea6d112a7afeadc7c004a4 Mon Sep 17 00:00:00 2001
2 From: Aurelien Jarno <aurelien@aurel32.net>
3 Date: Wed, 19 Sep 2012 22:00:22 +0200
4 Subject: [PATCH] tcg/optimize: prefer the "op a, a, b" form for commutative
5  ops
6
7 The "op a, a, b" form is better handled on non-RISC host than the "op
8 a, b, a" form, so swap the arguments to this form when possible, and
9 when b is not a constant.
10
11 This reduces the number of generated instructions by a tiny bit.
12
13 Reviewed-by: Richard Henderson <rth@twiddle.net>
14 Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
15 Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
16 ---
17  tcg/optimize.c | 5 ++++-
18  1 file changed, 4 insertions(+), 1 deletion(-)
19
20 diff --git a/tcg/optimize.c b/tcg/optimize.c
21 index abe016a..c8ae50b 100644
22 --- a/tcg/optimize.c
23 +++ b/tcg/optimize.c
24 @@ -434,7 +434,10 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
25          CASE_OP_32_64(eqv):
26          CASE_OP_32_64(nand):
27          CASE_OP_32_64(nor):
28 -            if (temps[args[1]].state == TCG_TEMP_CONST) {
29 +            /* Prefer the constant in second argument, and then the form
30 +               op a, a, b, which is better handled on non-RISC hosts. */
31 +            if (temps[args[1]].state == TCG_TEMP_CONST || (args[0] == args[2]
32 +                && temps[args[2]].state != TCG_TEMP_CONST)) {
33                  tmp = args[1];
34                  args[1] = args[2];
35                  args[2] = tmp;
36 -- 
37 1.7.12.1
38