render / rpms / qemu

Forked from rpms/qemu 9 months ago
Clone

Blame 0073-tcg-optimize-optimize-op-r-a-a-movi-r-0.patch

5544c1
From 363479b4d4f729959eafb1209d48ad75e928c00a Mon Sep 17 00:00:00 2001
5544c1
From: Aurelien Jarno <aurelien@aurel32.net>
5544c1
Date: Tue, 18 Sep 2012 19:12:36 +0200
5544c1
Subject: [PATCH] tcg/optimize: optimize "op r, a, a => movi r, 0"
5544c1
5544c1
Now that it's possible to detect copies, we can optimize the case
5544c1
the "op r, a, a => movi r, 0". This helps in the computation of
5544c1
overflow flags when one of the two args is 0.
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 | 16 ++++++++++++++++
5544c1
 1 file changed, 16 insertions(+)
5544c1
5544c1
diff --git a/tcg/optimize.c b/tcg/optimize.c
5544c1
index b9a7da9..ceea644 100644
5544c1
--- a/tcg/optimize.c
5544c1
+++ b/tcg/optimize.c
5544c1
@@ -540,6 +540,22 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
5544c1
             break;
5544c1
         }
5544c1
 
5544c1
+        /* Simplify expression for "op r, a, a => movi r, 0" cases */
5544c1
+        switch (op) {
5544c1
+        CASE_OP_32_64(sub):
5544c1
+        CASE_OP_32_64(xor):
5544c1
+            if (temps_are_copies(args[1], args[2])) {
5544c1
+                gen_opc_buf[op_index] = op_to_movi(op);
5544c1
+                tcg_opt_gen_movi(gen_args, args[0], 0);
5544c1
+                gen_args += 2;
5544c1
+                args += 3;
5544c1
+                continue;
5544c1
+            }
5544c1
+            break;
5544c1
+        default:
5544c1
+            break;
5544c1
+        }
5544c1
+
5544c1
         /* Propagate constants through copy operations and do constant
5544c1
            folding.  Constants will be substituted to arguments by register
5544c1
            allocator where needed and possible.  Also detect copies. */
5544c1
-- 
5544c1
1.7.12.1
5544c1