From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:36734) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QNLjD-0007c7-3v for qemu-devel@nongnu.org; Fri, 20 May 2011 05:10:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QNLj8-0007Gs-FW for qemu-devel@nongnu.org; Fri, 20 May 2011 05:10:39 -0400 Received: from mail-qy0-f180.google.com ([209.85.216.180]:61744) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QNLj8-0007Gl-8P for qemu-devel@nongnu.org; Fri, 20 May 2011 05:10:34 -0400 Received: by qyk10 with SMTP id 10so2057203qyk.4 for ; Fri, 20 May 2011 02:10:33 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <201105201125.16972.jcmvbkbc@gmail.com> References: <1305671572-5899-1-git-send-email-jcmvbkbc@gmail.com> <1305671572-5899-20-git-send-email-jcmvbkbc@gmail.com> <4DD590D4.4070307@twiddle.net> <201105201125.16972.jcmvbkbc@gmail.com> Date: Fri, 20 May 2011 13:10:33 +0400 Message-ID: From: Max Filippov Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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 >> > + =A0 =A0if (env->sregs[LEND] !=3D v) { >> > + =A0 =A0 =A0 =A0tb_invalidate_phys_page_range( >> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0env->sregs[LEND] - 1, env->sregs[LEND= ], 0); >> > + =A0 =A0 =A0 =A0env->sregs[LEND] =3D v; >> > + =A0 =A0 =A0 =A0tb_invalidate_phys_page_range( >> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0env->sregs[LEND] - 1, env->sregs[LEND= ], 0); >> > + =A0 =A0} >> >> Why are you invalidating twice? > > TB at the old LEND and at the new. Although it will work correctly withou= t first invalidation. > >> > +static void gen_check_loop_end(DisasContext *dc, int slot) >> > +{ >> > + =A0 =A0if (option_enabled(dc, XTENSA_OPTION_LOOP) && >> > + =A0 =A0 =A0 =A0 =A0 =A0!(dc->tb->flags & XTENSA_TBFLAG_EXCM) && >> > + =A0 =A0 =A0 =A0 =A0 =A0dc->next_pc =3D=3D dc->lend) { >> > + =A0 =A0 =A0 =A0int label =3D gen_new_label(); >> > + >> > + =A0 =A0 =A0 =A0tcg_gen_brcondi_i32(TCG_COND_NE, cpu_SR[LEND], dc->ne= xt_pc, label); >> > + =A0 =A0 =A0 =A0tcg_gen_brcondi_i32(TCG_COND_EQ, cpu_SR[LCOUNT], 0, l= abel); >> > + =A0 =A0 =A0 =A0tcg_gen_subi_i32(cpu_SR[LCOUNT], cpu_SR[LCOUNT], 1); >> > + =A0 =A0 =A0 =A0gen_jump(dc, cpu_SR[LBEG]); >> > + =A0 =A0 =A0 =A0gen_set_label(label); >> > + =A0 =A0 =A0 =A0gen_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. Ok, I guess that I need to add gen_wsr_lbeg that invalidates TB at the current LEND, pretend that LBEG is constant and use given slot to jump to it. And also to get rid of tcg_gen_brcondi_i32(TCG_COND_NE, cpu_SR[LEND], dc->next_pc, label); --=20 Thanks. -- Max