dcavalca / rpms / qemu

Forked from rpms/qemu a year ago
Clone

Blame 0024-tcg-optimize-add-constant-folding-for-brcond.patch

5544c1
From 98dc31743b94d5719c02c589e7cd652e95570b25 Mon Sep 17 00:00:00 2001
5544c1
From: Aurelien Jarno <aurelien@aurel32.net>
5544c1
Date: Thu, 6 Sep 2012 16:47:14 +0200
5544c1
Subject: [PATCH] tcg/optimize: add constant folding for brcond
5544c1
5544c1
Reviewed-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 | 27 ++++++++++++++++++++++++++-
5544c1
 1 file changed, 26 insertions(+), 1 deletion(-)
5544c1
5544c1
diff --git a/tcg/optimize.c b/tcg/optimize.c
5544c1
index 1cb1f36..156e8d9 100644
5544c1
--- a/tcg/optimize.c
5544c1
+++ b/tcg/optimize.c
5544c1
@@ -603,6 +603,32 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
5544c1
                 args += 4;
5544c1
                 break;
5544c1
             }
5544c1
+        CASE_OP_32_64(brcond):
5544c1
+            if (temps[args[0]].state == TCG_TEMP_CONST
5544c1
+                && temps[args[1]].state == TCG_TEMP_CONST) {
5544c1
+                if (do_constant_folding_cond(op, temps[args[0]].val,
5544c1
+                                             temps[args[1]].val, args[2])) {
5544c1
+                    memset(temps, 0, nb_temps * sizeof(struct tcg_temp_info));
5544c1
+                    gen_opc_buf[op_index] = INDEX_op_br;
5544c1
+                    gen_args[0] = args[3];
5544c1
+                    gen_args += 1;
5544c1
+                    args += 4;
5544c1
+                } else {
5544c1
+                    gen_opc_buf[op_index] = INDEX_op_nop;
5544c1
+                    args += 4;
5544c1
+                }
5544c1
+                break;
5544c1
+            } else {
5544c1
+                memset(temps, 0, nb_temps * sizeof(struct tcg_temp_info));
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;
5544c1
+                args += 4;
5544c1
+                break;
5544c1
+            }
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
@@ -624,7 +650,6 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
5544c1
         case INDEX_op_set_label:
5544c1
         case INDEX_op_jmp:
5544c1
         case INDEX_op_br:
5544c1
-        CASE_OP_32_64(brcond):
5544c1
             memset(temps, 0, nb_temps * sizeof(struct tcg_temp_info));
5544c1
             for (i = 0; i < def->nb_args; i++) {
5544c1
                 *gen_args = *args;
5544c1
-- 
5544c1
1.7.12.1
5544c1