From patchwork Thu Sep 20 00:29:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 185270 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 8827A2C0086 for ; Thu, 20 Sep 2012 10:29:29 +1000 (EST) Received: from localhost ([::1]:52054 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TEUdz-0000bY-4A for incoming@patchwork.ozlabs.org; Wed, 19 Sep 2012 20:29:27 -0400 Received: from eggs.gnu.org ([208.118.235.92]:49377) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TEUds-0000bT-5Y for qemu-devel@nongnu.org; Wed, 19 Sep 2012 20:29:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TEUdr-0000k9-0w for qemu-devel@nongnu.org; Wed, 19 Sep 2012 20:29:20 -0400 Received: from mail-ob0-f173.google.com ([209.85.214.173]:50731) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TEUdq-0000k2-Ri for qemu-devel@nongnu.org; Wed, 19 Sep 2012 20:29:18 -0400 Received: by obbta14 with SMTP id ta14so1507066obb.4 for ; Wed, 19 Sep 2012 17:29:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=L3/sE8rLkTQxixnLUnSXp/vcnSpv0mT/CRMgKpIvPkE=; b=pSmSjm5Ib9VOmHoxXRLK3+iNSFIJCezvkvQ5/lpJHve8v/smppauoudt9VooltFbLH KdQGQMmHECnR8O8M/sDPyPkj0NPWKnXbOAeQ9AuJxGfr8c/ffmBkbiIX9jzT4ceYXC7y lshHM310w82QhFmn7vNF8kpmjQOOvIXwP2DfWkOqhyJQE8ouhuIQZHZndXX3OOP+xc/m sBPcwkkm+uBJS/qqsXI0HZOXHagP4t/1BpUQ1mzCcxQYJ4Paik4bPs/nsuGFXKLpOXd6 I4ox9vQwYT3hvHmpin0q9WgULJoeAaFd0n0SfG7A1b45z6vjy/GWqqlmlE+6uYZUi8dY n6NQ== MIME-Version: 1.0 Received: by 10.182.85.8 with SMTP id d8mr78966obz.70.1348100957892; Wed, 19 Sep 2012 17:29:17 -0700 (PDT) Received: by 10.182.50.102 with HTTP; Wed, 19 Sep 2012 17:29:17 -0700 (PDT) In-Reply-To: <505A22C8.6030409@twiddle.net> References: <5059FA36.1080301@twiddle.net> <505A011C.1020106@twiddle.net> <20120919175116.GC29951@hall.aurel32.net> <505A0895.8000008@twiddle.net> <505A22C8.6030409@twiddle.net> Date: Thu, 20 Sep 2012 04:29:17 +0400 Message-ID: From: Max Filippov To: Richard Henderson X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.214.173 Cc: Peter Maydell , qemu-devel@nongnu.org, Aurelien Jarno Subject: Re: [Qemu-devel] Shifts, ppc[64], xtensa 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 Wed, Sep 19, 2012 at 11:53 PM, Richard Henderson wrote: > On 09/19/2012 11:30 AM, Peter Maydell wrote: >> ...but on the other hand that ought to work for PPC too, so >> presumably my analysis is wrong somewhere. > > It isn't. It's a target-xtensa bug. > >> OP: >> ---- 0xd0079cff >> movi_i32 tmp0,$0xd0079cff >> movi_i32 tmp1,$0x2 >> movi_i32 tmp2,$0x1 >> movi_i32 tmp3,$advance_ccount >> call tmp3,$0x0,$0,env,tmp2 >> movi_i32 tmp2,$window_check >> call tmp2,$0x0,$0,env,tmp0,tmp1 >> and_i32 tmp0,ar9,ar8 >> movi_i32 tmp1,$0x0 >> brcond_i32 tmp0,tmp1,eq,$0x0 >> movi_i32 tmp2,$0x0 >> brcond_i32 LCOUNT,tmp2,eq,$0x1 >> movi_i32 tmp2,$0x1 >> sub_i32 LCOUNT,LCOUNT,tmp2 >> movi_i32 tmp2,$0xd0079cf2 >> mov_i32 pc,tmp2 >> goto_tb $0x0 >> exit_tb $0x4a116558 >> set_label $0x1 >> movi_i32 tmp2,$0xd0079d02 >> mov_i32 pc,tmp2 >> exit_tb $0x0 >> set_label $0x0 >> movi_i32 tmp2,$0xd0079d1a >> mov_i32 pc,tmp2 >> goto_tb $0x1 >> exit_tb $0x4a116559 >> movi_i32 tmp0,$0x0 >> brcond_i32 LCOUNT,tmp0,eq,$0x2 >> movi_i32 tmp0,$0x1 >> sub_i32 LCOUNT,LCOUNT,tmp0 >> movi_i32 tmp0,$0xd0079cf2 >> mov_i32 pc,tmp0 >> goto_tb $0x0 >> exit_tb $0x4a116558 >> set_label $0x2 >> movi_i32 tmp0,$0xd0079d02 >> mov_i32 pc,tmp0 >> exit_tb $0x0 > > There are two instances of goto_tb $0 in here. > And, amusingly, two checks for LCOUNT. > > Since there's no disassembler for xtensa, I'll > leave it to the maintainer to track down from > whence this mistake stems. This code is generated when TB ends on LEND (zero-overhead loop ending) with branching instruction. So, in addition to 3 way branch there's extra looping code generated by unconditional gen_check_loop_end(dc, 0); at the end of disas_xtensa_insn. I was pretty sure that this dead code would make no harm. --enable-debug-tcg says nothing on x86_64 host. The following should fix that: -- >8 -- From: Max Filippov Date: Thu, 20 Sep 2012 04:07:20 +0400 Subject: [PATCH] target-xtensa: don't emit extra gen_check_loop_end Unconditional gen_check_loop_end at the end of disas_xtensa_insn can emit tcg_gen_goto_tb with slot id already used in the TB (e.g. when TB ends at LEND with a branch). Not all tcg backends can handle that. Signed-off-by: Max Filippov --- target-xtensa/translate.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/target-xtensa/translate.c b/target-xtensa/translate.c index 63b37b3..57a2b6f 100644 --- a/target-xtensa/translate.c +++ b/target-xtensa/translate.c @@ -2502,7 +2502,9 @@ static void disas_xtensa_insn(DisasContext *dc) break; } - gen_check_loop_end(dc, 0); + if (dc->is_jmp == DISAS_NEXT) { + gen_check_loop_end(dc, 0); + } dc->pc = dc->next_pc; return;