From patchwork Wed Nov 7 13:26:58 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Batuzov X-Patchwork-Id: 197671 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9F6FB2C0193 for ; Thu, 8 Nov 2012 00:27:23 +1100 (EST) Received: from localhost ([::1]:55528 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TW5f5-0004wN-O8 for incoming@patchwork.ozlabs.org; Wed, 07 Nov 2012 08:27:19 -0500 Received: from eggs.gnu.org ([208.118.235.92]:35450) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TW5ey-0004vD-2V for qemu-devel@nongnu.org; Wed, 07 Nov 2012 08:27:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TW5er-00073H-DD for qemu-devel@nongnu.org; Wed, 07 Nov 2012 08:27:11 -0500 Received: from smtp.ispras.ru ([83.149.198.202]:41257) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TW5er-00071x-1e for qemu-devel@nongnu.org; Wed, 07 Nov 2012 08:27:05 -0500 Received: from spartak.intra.ispras.ru (unknown [83.149.198.253]) by smtp.ispras.ru (Postfix) with ESMTP id B48425D4038; Wed, 7 Nov 2012 16:25:27 +0300 (MSK) Date: Wed, 7 Nov 2012 17:26:58 +0400 (MSK) From: Kirill Batuzov To: Aurelien Jarno In-Reply-To: <20121030235636.GB32197@hall.aurel32.net> Message-ID: References: <508EC28A.5060706@redhat.com> <20121029182958.GB29866@ohm.aurel32.net> <508F8CBB.8090101@redhat.com> <509053A2.6010504@weilnetz.de> <20121030235636.GB32197@hall.aurel32.net> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 83.149.198.202 Cc: Stefan Weil , qemu-devel , Paolo Bonzini Subject: Re: [Qemu-devel] 64-on-32 TCG broken X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org > diff --git a/tcg/tcg.c b/tcg/tcg.c > index c3a7f19..1133438 100644 > --- a/tcg/tcg.c > +++ b/tcg/tcg.c > @@ -1329,8 +1329,8 @@ static void tcg_liveness_analysis(TCGContext *s) > the low part. The result can be optimized to a simple > add or sub. This happens often for x86_64 guest when the > cpu mode is set to 32 bit. */ > - if (dead_temps[args[1]]) { > - if (dead_temps[args[0]]) { > + if (dead_temps[args[1]] && !mem_temps[1]) { > + if (dead_temps[args[0]] && !mem_temps[0]) { This should be mem_temps[args[1]] and mem_temps[args[0]] I believe. > goto do_remove; > } > /* Create the single operation plus nop. */ > @@ -1355,8 +1355,8 @@ static void tcg_liveness_analysis(TCGContext *s) > nb_iargs = 2; > nb_oargs = 2; > /* Likewise, test for the high part of the operation dead. */ > - if (dead_temps[args[1]]) { > - if (dead_temps[args[0]]) { > + if (dead_temps[args[1]] && !mem_temps[1]) { > + if (dead_temps[args[0]] && !mem_temps[0]) { Same here. > goto do_remove; > } > gen_opc_buf[op_index] = op = INDEX_op_mul_i32; Looks like for x86_64 guest temp 0 is the env (always mem_temp), temp 1 - cc_op. As a result it can accidentally remove high part of operation when it is actually alive but will never optimize out whole operation even if its output is really dead. I've attached a small patch to fix this issue. I was not able to boot gentoo install CD (amd64) with current trunk. Boot process hangs soon after framebuffer initialization. With the patch it boots successfully. Command line to reproduce: qemu-system-x86_64 -cdrom install-amd64-minimal-20121013.iso From 33e1fc03934cebea8d32c98ea34961c80f05d94a Mon Sep 17 00:00:00 2001 From: Kirill Batuzov Date: Wed, 7 Nov 2012 15:26:38 +0400 Subject: [PATCH] tcg: properly check that op's output needs to be synced to memory Fix typo introduced in b3a1be87bac3a6aaa59bb88c1410f170dc9b22d5. Reported-by: Ruslan Savchenko Signed-off-by: Kirill Batuzov --- tcg/tcg.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index 42052db..35fba50 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1337,8 +1337,8 @@ static void tcg_liveness_analysis(TCGContext *s) the low part. The result can be optimized to a simple add or sub. This happens often for x86_64 guest when the cpu mode is set to 32 bit. */ - if (dead_temps[args[1]] && !mem_temps[1]) { - if (dead_temps[args[0]] && !mem_temps[0]) { + if (dead_temps[args[1]] && !mem_temps[args[1]]) { + if (dead_temps[args[0]] && !mem_temps[args[0]]) { goto do_remove; } /* Create the single operation plus nop. */ @@ -1363,8 +1363,8 @@ static void tcg_liveness_analysis(TCGContext *s) nb_iargs = 2; nb_oargs = 2; /* Likewise, test for the high part of the operation dead. */ - if (dead_temps[args[1]] && !mem_temps[1]) { - if (dead_temps[args[0]] && !mem_temps[0]) { + if (dead_temps[args[1]] && !mem_temps[args[1]]) { + if (dead_temps[args[0]] && !mem_temps[args[0]]) { goto do_remove; } gen_opc_buf[op_index] = op = INDEX_op_mul_i32; -- 1.7.9.5