From patchwork Wed Jul 15 10:02:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 495743 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E3A791402B6 for ; Wed, 15 Jul 2015 20:02:50 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=yt++psnA; dkim-atps=neutral Received: from localhost ([::1]:34823 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFJWZ-00018U-HG for incoming@patchwork.ozlabs.org; Wed, 15 Jul 2015 06:02:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39520) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFJWI-0000rS-NG for qemu-devel@nongnu.org; Wed, 15 Jul 2015 06:02:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZFJWE-0007BT-MT for qemu-devel@nongnu.org; Wed, 15 Jul 2015 06:02:30 -0400 Received: from mail-wi0-x232.google.com ([2a00:1450:400c:c05::232]:35813) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFJWE-0007Al-Ex for qemu-devel@nongnu.org; Wed, 15 Jul 2015 06:02:26 -0400 Received: by wiga1 with SMTP id a1so123939249wig.0 for ; Wed, 15 Jul 2015 03:02:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-type; bh=iZd9Y67feP3X8k5aYS43eGHFOMlCZYFCUGKxma2g4ng=; b=yt++psnAmMgH8EBmu5XhT3bM3Pop/tPYQy+3OwWcLw7X/kqhZN9aOcu8nUFTsWmZvj qz3GUWJeOf2m1z/QX+g1a+Gxpc8P2i4TVADbtpOZxKzoq4N2Df3V9mQjWkaOuK/N1UP+ /z+lGi1PhbBaqA/wnISplWOuw47HbEWnqOmih4GIQCLbIK2lUnyNZr7I4lYPHjSJfJE3 8nc+fTlQpEULlDQnQBltnYjXoH0HxiZBfb8l0zlsJGZwas3bEIHwAYff3yyJSXQyfQnR mxmYlOpnjCAAd4L2SnSSViOClyPANq7dgC3m17LAYLLNigyEV+H0Pjx8r+IfkVBkNUkU rDww== X-Received: by 10.180.82.134 with SMTP id i6mr4931919wiy.15.1436954545620; Wed, 15 Jul 2015 03:02:25 -0700 (PDT) Received: from bigtime.twiddle.net (host109-151-85-12.range109-151.btcentralplus.com. [109.151.85.12]) by smtp.googlemail.com with ESMTPSA id d17sm7076216wjs.32.2015.07.15.03.02.24 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Jul 2015 03:02:24 -0700 (PDT) To: Aurelien Jarno , Paolo Bonzini References: <1436891912-14742-1-git-send-email-leon.alrae@imgtec.com> <20150714170928.GC7569@aurel32.net> <55A552F1.70000@redhat.com> <20150714183735.GA2685@aurel32.net> <55A57792.5070509@redhat.com> <20150714220938.GA11278@aurel32.net> <55A60C4C.3070406@redhat.com> <20150715080633.GJ11361@aurel32.net> From: Richard Henderson Message-ID: <55A62FAE.7030806@twiddle.net> Date: Wed, 15 Jul 2015 11:02:22 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 MIME-Version: 1.0 In-Reply-To: <20150715080633.GJ11361@aurel32.net> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::232 Cc: Leon Alrae , qemu-devel@nongnu.org Subject: Re: [Qemu-devel] [PATCH] target-mips: apply workaround for TCG optimizations for MFC1 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 On 07/15/2015 09:06 AM, Aurelien Jarno wrote: > On 2015-07-15 09:31, Paolo Bonzini wrote: >> Ok, I see your point. If you put it like this :) the fault definitely >> lies in the backends. What I'm proposing would be in a new >> tcg_reg_alloc_trunc function, and it would require implementing a >> non-noop trunc. > > Why not reusing the existing trunc_shr_i64_i32 op? AFAIU, it has been > designed exactly for that. Indeed. > Actually I think we should implement the following ops as optional but > *real* TCG ops: > - trunc_shr_i64_i32 > - extu_i32_i64 > - ext_i32_i64 While we could perhaps gain something from the last two, reliably using the first is probably the most important. I've been unable to reproduce the binary in question. I'm curious if something as simple as this helps. Alternately, the two hunks might just cancel each other out and result in no change. r~ diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index 45098c3..cc223c1 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -1751,17 +1751,17 @@ void tcg_gen_trunc_shr_i64_i32(TCGv_i32 ret, TCGv_i64 arg, unsigned count) tcg_gen_mov_i32(ret, TCGV_LOW(t)); tcg_temp_free_i64(t); } - } else if (TCG_TARGET_HAS_trunc_shr_i32) { - tcg_gen_op3i_i32(INDEX_op_trunc_shr_i32, ret, - MAKE_TCGV_I32(GET_TCGV_I64(arg)), count); - } else if (count == 0) { - tcg_gen_mov_i32(ret, MAKE_TCGV_I32(GET_TCGV_I64(arg))); - } else { + return; + } + if (!TCG_TARGET_HAS_trunc_shr_i32 && count != 0) { TCGv_i64 t = tcg_temp_new_i64(); tcg_gen_shri_i64(t, arg, count); - tcg_gen_mov_i32(ret, MAKE_TCGV_I32(GET_TCGV_I64(t))); tcg_temp_free_i64(t); + arg = t; + count = 0; } + tcg_gen_op3i_i32(INDEX_op_trunc_shr_i32, ret, + MAKE_TCGV_I32(GET_TCGV_I64(arg)), count); } void tcg_gen_extu_i32_i64(TCGv_i64 ret, TCGv_i32 arg) diff --git a/tcg/tcg.c b/tcg/tcg.c index 7e088b1..334d4c3 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -2374,6 +2374,13 @@ static inline int tcg_gen_code_common(TCGContext *s, tcg_reg_alloc_call(s, op->callo, op->calli, args, dead_args, sync_args); break; + case INDEX_op_trunc_shr_i32: + if (!TCG_TARGET_HAS_trunc_shr_i32) { + tcg_assert(args[2] == 0); + tcg_reg_alloc_mov(s, def, args, dead_args, sync_args); + break; + } + /* FALLTHRU */ default: /* Sanity check that we've not introduced any unhandled opcodes. */ if (def->flags & TCG_OPF_NOT_PRESENT) {