Received: from eggs.gnu.org ([2001:4830:134:3::10]:36671) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z0b6i-0008Pc-8j for qemu-devel@nongnu.org; Thu, 04 Jun 2015 15:47:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z0b6g-00012N-9R for qemu-devel@nongnu.org; Thu, 04 Jun 2015 15:47:16 -0400 Received: from hall.aurel32.net ([2001:bc8:30d7:101::1]:45459) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z0b6g-00011e-3Q for qemu-devel@nongnu.org; Thu, 04 Jun 2015 15:47:14 -0400 From: Aurelien Jarno Date: Thu, 4 Jun 2015 21:47:07 +0200 Message-Id: <1433447228-29425-2-git-send-email-aurelien@aurel32.net> In-Reply-To: <1433447228-29425-1-git-send-email-aurelien@aurel32.net> References: <1433447228-29425-1-git-send-email-aurelien@aurel32.net> Subject: [Qemu-devel] [PATCH v3 1/2] tcg: fix register allocation with two aliased dead inputs List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Aurelien Jarno , Richard Henderson For TCG ops with two outputs registers (add2, sub2, div2, div2u), when the same input temp is used for the two inputs aliased to the two outputs, and when these inputs are both dead, the register allocation code wrongly assigned the same register to the same output. This happens for example with sub2 t1, t2, t3, t3, t4, t5, when t3 is not used anymore after the TCG op. In that case the same register is used for t1, t2 and t3. The fix is to look for already allocated aliased input when allocating a dead aliased input and check that the register is not already used. Cc: Richard Henderson Signed-off-by: Aurelien Jarno --- tcg/tcg.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tcg/tcg.c b/tcg/tcg.c index 8b43bbb..c5e2ce9 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1998,6 +1998,16 @@ static void tcg_reg_alloc_op(TCGContext *s, if (!IS_DEAD_ARG(i)) { goto allocate_in_reg; } + /* check if the current register has already been allocated + for another input aliased to an output */ + int k2, i2; + for (k2 = 0 ; k2 < k ; k2++) { + i2 = def->sorted_args[nb_oargs + k2]; + if ((def->args_ct[i2].ct & TCG_CT_IALIAS) && + (new_args[i2] == ts->reg)) { + goto allocate_in_reg; + } + } } } reg = ts->reg; -- 2.1.4