5544c1b
From 16f29b266435c7eaffc5081c6bba4651d56a8ce8 Mon Sep 17 00:00:00 2001
5544c1b
From: Aurelien Jarno <aurelien@aurel32.net>
5544c1b
Date: Thu, 6 Sep 2012 16:47:13 +0200
5544c1b
Subject: [PATCH] tcg/optimize: split expression simplification
5544c1b
5544c1b
Split expression simplification in multiple parts so that a given op
5544c1b
can appear multiple times. This patch should not change anything.
5544c1b
5544c1b
Reviewed-by: Richard Henderson <rth@twiddle.net>
5544c1b
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
5544c1b
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
5544c1b
---
5544c1b
 tcg/optimize.c | 14 +++++++++++++-
5544c1b
 1 file changed, 13 insertions(+), 1 deletion(-)
5544c1b
5544c1b
diff --git a/tcg/optimize.c b/tcg/optimize.c
5544c1b
index 9c65474..63f970d 100644
5544c1b
--- a/tcg/optimize.c
5544c1b
+++ b/tcg/optimize.c
5544c1b
@@ -322,7 +322,7 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
5544c1b
             break;
5544c1b
         }
5544c1b
 
5544c1b
-        /* Simplify expression if possible. */
5544c1b
+        /* Simplify expression for "op r, a, 0 => mov r, a" cases */
5544c1b
         switch (op) {
5544c1b
         CASE_OP_32_64(add):
5544c1b
         CASE_OP_32_64(sub):
5544c1b
@@ -352,6 +352,12 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
5544c1b
                 continue;
5544c1b
             }
5544c1b
             break;
5544c1b
+        default:
5544c1b
+            break;
5544c1b
+        }
5544c1b
+
5544c1b
+        /* Simplify expression for "op r, a, 0 => movi r, 0" cases */
5544c1b
+        switch (op) {
5544c1b
         CASE_OP_32_64(mul):
5544c1b
             if ((temps[args[2]].state == TCG_TEMP_CONST
5544c1b
                 && temps[args[2]].val == 0)) {
5544c1b
@@ -362,6 +368,12 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
5544c1b
                 continue;
5544c1b
             }
5544c1b
             break;
5544c1b
+        default:
5544c1b
+            break;
5544c1b
+        }
5544c1b
+
5544c1b
+        /* Simplify expression for "op r, a, a => mov r, a" cases */
5544c1b
+        switch (op) {
5544c1b
         CASE_OP_32_64(or):
5544c1b
         CASE_OP_32_64(and):
5544c1b
             if (args[1] == args[2]) {