From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:58395) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RUsQi-0005yj-Nn for qemu-devel@nongnu.org; Sun, 27 Nov 2011 23:02:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RUsQh-0002gU-Js for qemu-devel@nongnu.org; Sun, 27 Nov 2011 23:02:56 -0500 Received: from m15-5.126.com ([220.181.15.5]:40005) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RUsQe-0002fP-5F for qemu-devel@nongnu.org; Sun, 27 Nov 2011 23:02:55 -0500 Date: Mon, 28 Nov 2011 11:31:49 +0800 (CST) From: qemu_wanghuang Message-ID: <5dc6e67f.f305.133e83a87df.Coremail.qemu_wanghuang@126.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_169458_1849861657.1322451109855" Subject: [Qemu-devel] [PATCH] trivial:Loop invariant eode motion in tcg/optimize.c List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel ------=_Part_169458_1849861657.1322451109855 Content-Type: text/plain; charset=GBK Content-Transfer-Encoding: 7bit We find that the "new_base" doesn't change during in the following loop, so we can outer this judgement from this loop. Signed-off-by: Wanghuang diff --git a/qemu/tcg/optimize.c b/qemu-local/tcg/optimize.c index 9c65474..27164f0 100644 --- a/qemu/tcg/optimize.c +++ b/qemu-local/tcg/optimize.c @@ -67,12 +67,12 @@ static void reset_temp(TCGArg temp, int nb_temps, int nb_globals) break; } } - for (i = temps[temp].next_copy; i != temp; i = temps[i].next_copy) { - if (new_base == (TCGArg)-1) { + if (new_base == (TCGArg)-1) { + for (i = temps[temp].next_copy; i != temp; i = temps[i].next_copy) temps[i].state = TCG_TEMP_ANY; - } else { + } else { + for (i = temps[temp].next_copy; i != temp; i = temps[i].next_copy) temps[i].val = new_base; - } } temps[temps[temp].next_copy].prev_copy = temps[temp].prev_copy; temps[temps[temp].prev_copy].next_copy = temps[temp].next_copy; ------=_Part_169458_1849861657.1322451109855 Content-Type: text/html; charset=GBK Content-Transfer-Encoding: 7bit

We find that the "new_base" doesn't change during in the following loop, so we can outer this judgement from this loop.

Signed-off-by: Wanghuang <qemu_wanghuang@126.com>

diff --git a/qemu/tcg/optimize.c b/qemu-local/tcg/optimize.c

index 9c65474..27164f0 100644

--- a/qemu/tcg/optimize.c

+++ b/qemu-local/tcg/optimize.c

@@ -67,12 +67,12 @@ static void reset_temp(TCGArg temp, int nb_temps, int nb_globals)

                 break;

             }

         }

-        for (i = temps[temp].next_copy; i != temp; i = temps[i].next_copy) {

-            if (new_base == (TCGArg)-1) {

+       if (new_base == (TCGArg)-1) {

+           for (i = temps[temp].next_copy; i != temp; i = temps[i].next_copy) 

                 temps[i].state = TCG_TEMP_ANY;

-            } else {

+       } else { 

+          for (i = temps[temp].next_copy; i != temp; i = temps[i].next_copy) 

                 temps[i].val = new_base;

-            }

         }

         temps[temps[temp].next_copy].prev_copy = temps[temp].prev_copy;

         temps[temps[temp].prev_copy].next_copy = temps[temp].next_copy;




------=_Part_169458_1849861657.1322451109855--