Received: from eggs.gnu.org ([2001:4830:134:3::10]:34657) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VJ5Fy-0004oe-F1 for qemu-devel@nongnu.org; Mon, 09 Sep 2013 13:28:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VJ5Ft-0008T0-M9 for qemu-devel@nongnu.org; Mon, 09 Sep 2013 13:28:10 -0400 Received: from hall.aurel32.net ([2001:470:1f0b:4a8::1]:38644) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VJ5Ft-0008Sw-EU for qemu-devel@nongnu.org; Mon, 09 Sep 2013 13:28:05 -0400 From: Aurelien Jarno Date: Mon, 9 Sep 2013 19:27:48 +0200 Message-Id: <1378747670-25512-3-git-send-email-aurelien@aurel32.net> In-Reply-To: <1378747670-25512-1-git-send-email-aurelien@aurel32.net> References: <1378747670-25512-1-git-send-email-aurelien@aurel32.net> Subject: [Qemu-devel] [PATCH v2 2/4] tcg/optimize: fix known-zero bits optimization List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Aurelien Jarno , Richard Henderson Known-zero bits optimization is a great idea that helps to generate more optimized code. However the current implementation only works in very few cases as the computed mask is not saved. Fix this to make it really working. Cc: Richard Henderson Cc: Paolo Bonzini Signed-off-by: Aurelien Jarno --- tcg/optimize.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index c539e39..0ed8983 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -695,7 +695,8 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr, break; } - /* Simplify using known-zero bits */ + /* Simplify using known-zero bits. Currently only ops with a single + output argument is supported. */ mask = -1; affected = -1; switch (op) { @@ -1157,6 +1158,11 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr, } else { for (i = 0; i < def->nb_oargs; i++) { reset_temp(args[i]); + /* Save the corresponding known-zero bits mask for the + first output argument (only one supported so far). */ + if (i == 0) { + temps[args[i]].mask = mask; + } } } for (i = 0; i < def->nb_args; i++) { -- 1.7.10.4