render / rpms / qemu

Forked from rpms/qemu 9 months ago
Clone

Blame 0052-tcg-Optimize-movcond-for-constant-comparisons.patch

5544c1
From c489b380d3f827be91b5f8b80b88585fb4014fbb Mon Sep 17 00:00:00 2001
5544c1
From: Richard Henderson <rth@twiddle.net>
5544c1
Date: Fri, 21 Sep 2012 10:13:37 -0700
5544c1
Subject: [PATCH] tcg: Optimize movcond for constant comparisons
5544c1
5544c1
Signed-off-by: Richard Henderson <rth@twiddle.net>
5544c1
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
5544c1
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
5544c1
---
5544c1
 tcg/optimize.c | 40 ++++++++++++++++++++++++++++++++++++++++
5544c1
 1 file changed, 40 insertions(+)
5544c1
5544c1
diff --git a/tcg/optimize.c b/tcg/optimize.c
5544c1
index 9da333c..26038a6 100644
5544c1
--- a/tcg/optimize.c
5544c1
+++ b/tcg/optimize.c
5544c1
@@ -394,6 +394,14 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
5544c1
                 args[3] = tcg_swap_cond(args[3]);
5544c1
             }
5544c1
             break;
5544c1
+        CASE_OP_32_64(movcond):
5544c1
+            if (temps[args[1]].state == TCG_TEMP_CONST
5544c1
+                && temps[args[2]].state != TCG_TEMP_CONST) {
5544c1
+                tmp = args[1];
5544c1
+                args[1] = args[2];
5544c1
+                args[2] = tmp;
5544c1
+                args[5] = tcg_swap_cond(args[5]);
5544c1
+            }
5544c1
         default:
5544c1
             break;
5544c1
         }
5544c1
@@ -614,6 +622,38 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
5544c1
             }
5544c1
             args += 4;
5544c1
             break;
5544c1
+        CASE_OP_32_64(movcond):
5544c1
+            if (temps[args[1]].state == TCG_TEMP_CONST
5544c1
+                && temps[args[2]].state == TCG_TEMP_CONST) {
5544c1
+                tmp = do_constant_folding_cond(op, temps[args[1]].val,
5544c1
+                                               temps[args[2]].val, args[5]);
5544c1
+                if (args[0] == args[4-tmp]
5544c1
+                    || (temps[args[4-tmp]].state == TCG_TEMP_COPY
5544c1
+                        && temps[args[4-tmp]].val == args[0])) {
5544c1
+                    gen_opc_buf[op_index] = INDEX_op_nop;
5544c1
+                } else if (temps[args[4-tmp]].state == TCG_TEMP_CONST) {
5544c1
+                    gen_opc_buf[op_index] = op_to_movi(op);
5544c1
+                    tcg_opt_gen_movi(gen_args, args[0], temps[args[4-tmp]].val,
5544c1
+                                     nb_temps, nb_globals);
5544c1
+                    gen_args += 2;
5544c1
+                } else {
5544c1
+                    gen_opc_buf[op_index] = op_to_mov(op);
5544c1
+                    tcg_opt_gen_mov(gen_args, args[0], args[4-tmp],
5544c1
+                                    nb_temps, nb_globals);
5544c1
+                    gen_args += 2;
5544c1
+                }
5544c1
+            } else {
5544c1
+                reset_temp(args[0], nb_temps, nb_globals);
5544c1
+                gen_args[0] = args[0];
5544c1
+                gen_args[1] = args[1];
5544c1
+                gen_args[2] = args[2];
5544c1
+                gen_args[3] = args[3];
5544c1
+                gen_args[4] = args[4];
5544c1
+                gen_args[5] = args[5];
5544c1
+                gen_args += 6;
5544c1
+            }
5544c1
+            args += 6;
5544c1
+            break;
5544c1
         case INDEX_op_call:
5544c1
             nb_call_args = (args[0] >> 16) + (args[0] & 0xffff);
5544c1
             if (!(args[nb_call_args + 1] & (TCG_CALL_CONST | TCG_CALL_PURE))) {
5544c1
-- 
5544c1
1.7.12.1
5544c1