dcavalca / rpms / qemu

Forked from rpms/qemu a year ago
Clone

Blame 0021-tcg-optimize-simplify-shift-rot-r-0-a-movi-r-0-cases.patch

5544c1
From bbed332c7ad12e9885d3f457f366fa0b29445dcd 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: simplify shift/rot r, 0, a => movi r, 0 cases
5544c1
5544c1
shift/rot r, 0, a is equivalent to movi r, 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 | 20 ++++++++++++++++++++
5544c1
 1 file changed, 20 insertions(+)
5544c1
5544c1
diff --git a/tcg/optimize.c b/tcg/optimize.c
5544c1
index c12cb2b..1698ba3 100644
5544c1
--- a/tcg/optimize.c
5544c1
+++ b/tcg/optimize.c
5544c1
@@ -322,6 +322,26 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
5544c1
             break;
5544c1
         }
5544c1
 
5544c1
+        /* Simplify expressions for "shift/rot r, 0, a => movi r, 0" */
5544c1
+        switch (op) {
5544c1
+        CASE_OP_32_64(shl):
5544c1
+        CASE_OP_32_64(shr):
5544c1
+        CASE_OP_32_64(sar):
5544c1
+        CASE_OP_32_64(rotl):
5544c1
+        CASE_OP_32_64(rotr):
5544c1
+            if (temps[args[1]].state == TCG_TEMP_CONST
5544c1
+                && temps[args[1]].val == 0) {
5544c1
+                gen_opc_buf[op_index] = op_to_movi(op);
5544c1
+                tcg_opt_gen_movi(gen_args, args[0], 0, nb_temps, nb_globals);
5544c1
+                args += 3;
5544c1
+                gen_args += 2;
5544c1
+                continue;
5544c1
+            }
5544c1
+            break;
5544c1
+        default:
5544c1
+            break;
5544c1
+        }
5544c1
+
5544c1
         /* Simplify expression for "op r, a, 0 => mov r, a" cases */
5544c1
         switch (op) {
5544c1
         CASE_OP_32_64(add):
5544c1
-- 
5544c1
1.7.12.1
5544c1