Received: from eggs.gnu.org ([2001:4830:134:3::10]:43460) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yuejo-0000dN-Ho for qemu-devel@nongnu.org; Tue, 19 May 2015 06:27:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yuejk-0006SH-2I for qemu-devel@nongnu.org; Tue, 19 May 2015 06:27:04 -0400 Received: from hall.aurel32.net ([2001:bc8:30d7:101::1]:36373) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yuejj-0006Rs-Sc for qemu-devel@nongnu.org; Tue, 19 May 2015 06:26:59 -0400 From: Aurelien Jarno Date: Tue, 19 May 2015 12:26:48 +0200 Message-Id: <1432031208-20020-1-git-send-email-aurelien@aurel32.net> Subject: [Qemu-devel] [PATCH] tcg: fix dead computation for repeated input arguments List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Aurelien Jarno , Richard Henderson When the same temp is used twice or more as an input argument to a TCG instruction, the dead computation code doesn't recognize the second use as a dead temp. This is because the temp is marked as live in the same loop where dead inputs are checked. The fix is to split the loop in two parts. This avoid emitting a move and using a register for the movcond instruction when used as "move if true" on x86-64. This might bring more improvements on RISC TCG targets which don't have outputs aliased to inputs. Cc: Richard Henderson Signed-off-by: Aurelien Jarno --- tcg/tcg.c | 3 +++ 1 file changed, 3 insertions(+) NB: The dead computation loop for call has the same problem, but it will not improve the generated code as anyway the value has to be copied to a register or memory. I am therefore not sure it is worth fixing it as it might bring some performance penalty. diff --git a/tcg/tcg.c b/tcg/tcg.c index f1558b7..58ca693 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1522,6 +1522,9 @@ static void tcg_liveness_analysis(TCGContext *s) if (dead_temps[arg]) { dead_args |= (1 << i); } + } + for (i = nb_oargs; i < nb_oargs + nb_iargs; i++) { + arg = args[i]; dead_temps[arg] = 0; } s->op_dead_args[oi] = dead_args; -- 2.1.4