From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43231) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YFhax-0004hu-Qq for qemu-devel@nongnu.org; Mon, 26 Jan 2015 06:12:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YFhav-0001Rx-Af for qemu-devel@nongnu.org; Mon, 26 Jan 2015 06:12:39 -0500 Sender: Paolo Bonzini From: Paolo Bonzini Date: Mon, 26 Jan 2015 12:12:22 +0100 Message-Id: <1422270747-23994-3-git-send-email-pbonzini@redhat.com> In-Reply-To: <1422270747-23994-1-git-send-email-pbonzini@redhat.com> References: <1422270747-23994-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 2/7] cpu-exec: simplify icount code List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, armbru@redhat.com Use MIN instead of an "if" statement. Move "tb" assignment where the value is actually used. Signed-off-by: Paolo Bonzini --- cpu-exec.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/cpu-exec.c b/cpu-exec.c index 7aab86d..af56a34 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -502,22 +502,17 @@ int cpu_exec(CPUArchState *env) case TB_EXIT_ICOUNT_EXPIRED: { /* Instruction counter expired. */ - int insns_left; - tb = (TranslationBlock *)(next_tb & ~TB_EXIT_MASK); - insns_left = cpu->icount_decr.u32; + int insns_left = cpu->icount_decr.u32; if (cpu->icount_extra && insns_left >= 0) { /* Refill decrementer and continue execution. */ cpu->icount_extra += insns_left; - if (cpu->icount_extra > 0xffff) { - insns_left = 0xffff; - } else { - insns_left = cpu->icount_extra; - } + insns_left = MIN(0xffff, cpu->icount_extra); cpu->icount_extra -= insns_left; cpu->icount_decr.u16.low = insns_left; } else { if (insns_left > 0) { /* Execute remaining instructions. */ + tb = (TranslationBlock *)(next_tb & ~TB_EXIT_MASK); cpu_exec_nocache(env, insns_left, tb); align_clocks(&sc, cpu); } -- 1.8.3.1