From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:59207) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QNK5K-00080t-Cr for qemu-devel@nongnu.org; Fri, 20 May 2011 03:25:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QNK5J-0007Ah-8X for qemu-devel@nongnu.org; Fri, 20 May 2011 03:25:22 -0400 Received: from mail-bw0-f45.google.com ([209.85.214.45]:38044) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QNK5J-0007AV-3z for qemu-devel@nongnu.org; Fri, 20 May 2011 03:25:21 -0400 Received: by bwz16 with SMTP id 16so2996751bwz.4 for ; Fri, 20 May 2011 00:25:20 -0700 (PDT) From: Max Filippov Date: Fri, 20 May 2011 11:25:16 +0400 References: <1305671572-5899-1-git-send-email-jcmvbkbc@gmail.com> <1305671572-5899-20-git-send-email-jcmvbkbc@gmail.com> <4DD590D4.4070307@twiddle.net> In-Reply-To: <4DD590D4.4070307@twiddle.net> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201105201125.16972.jcmvbkbc@gmail.com> Subject: Re: [Qemu-devel] [PATCH 19/26] target-xtensa: implement loop option List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Richard Henderson Cc: qemu-devel@nongnu.org > > + if (env->sregs[LEND] != v) { > > + tb_invalidate_phys_page_range( > > + env->sregs[LEND] - 1, env->sregs[LEND], 0); > > + env->sregs[LEND] = v; > > + tb_invalidate_phys_page_range( > > + env->sregs[LEND] - 1, env->sregs[LEND], 0); > > + } > > Why are you invalidating twice? TB at the old LEND and at the new. Although it will work correctly without first invalidation. > > +static void gen_check_loop_end(DisasContext *dc, int slot) > > +{ > > + if (option_enabled(dc, XTENSA_OPTION_LOOP) && > > + !(dc->tb->flags & XTENSA_TBFLAG_EXCM) && > > + dc->next_pc == dc->lend) { > > + int label = gen_new_label(); > > + > > + tcg_gen_brcondi_i32(TCG_COND_NE, cpu_SR[LEND], dc->next_pc, label); > > + tcg_gen_brcondi_i32(TCG_COND_EQ, cpu_SR[LCOUNT], 0, label); > > + tcg_gen_subi_i32(cpu_SR[LCOUNT], cpu_SR[LCOUNT], 1); > > + gen_jump(dc, cpu_SR[LBEG]); > > + gen_set_label(label); > > + gen_jumpi(dc, dc->next_pc, slot); > > If you're going to pretend that LEND is a constant, you might as well > pretend that LBEG is also a constant, so that you get to chain the TB's > around the loop. But there may be three exits from TB at the LEND if its last command is a branch: to the LBEG, to the branch target and to the next insn. Thanks. -- Max