From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:36982) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THMPm-0005ZU-If for qemu-devel@nongnu.org; Thu, 27 Sep 2012 18:18:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1THMPl-0004hJ-IF for qemu-devel@nongnu.org; Thu, 27 Sep 2012 18:18:38 -0400 Received: from mail-da0-f45.google.com ([209.85.210.45]:60062) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THMPl-0004h4-Bc for qemu-devel@nongnu.org; Thu, 27 Sep 2012 18:18:37 -0400 Received: by dadn15 with SMTP id n15so495428dad.4 for ; Thu, 27 Sep 2012 15:18:36 -0700 (PDT) Sender: Richard Henderson Message-ID: <5064D0BA.5020103@twiddle.net> Date: Thu, 27 Sep 2012 15:18:34 -0700 From: Richard Henderson MIME-Version: 1.0 References: <1348766113-18373-1-git-send-email-aurelien@aurel32.net> <1348766113-18373-8-git-send-email-aurelien@aurel32.net> In-Reply-To: <1348766113-18373-8-git-send-email-aurelien@aurel32.net> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 07/13] tcg: rewrite tcg_reg_alloc_mov() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Aurelien Jarno Cc: qemu-devel@nongnu.org On 09/27/2012 10:15 AM, Aurelien Jarno wrote: > + /* We have to load the value in a register for moving it to another > + or for saving it. We assume it's better to keep it there than to > + reload it later. */ > + if ((NEED_SYNC_ARG(0) && ts->val_type != TEMP_VAL_REG) > + || ts->val_type == TEMP_VAL_MEM) { > + ts->reg = tcg_reg_alloc(s, arg_ct->u.regs, allocated_regs); > + if (ts->val_type == TEMP_VAL_MEM) { > + tcg_out_ld(s, ts->type, ts->reg, ts->mem_reg, ts->mem_offset); > + } else if (ts->val_type == TEMP_VAL_CONST) { > + tcg_out_movi(s, ts->type, ts->reg, ts->val); > + } > + s->reg_to_temp[ts->reg] = args[1]; > + ts->val_type = TEMP_VAL_REG; > + ts->mem_coherent = 1; > + } Ok, I believe I understand what's going on now. Nothing like trying to rewrite the function yourself to figure out why you've done things this way. The only thing I'd change for clarity is that first condition: /* If the source value is not in a register, and we're going to be forced to have it in a register in order to perform the copy, then copy the SOURCE value into its own register first. That way we don't have to reload SOURCE the next time it is used. Note that in the CONST + SYNC case, we must for the moment have the value in a register because we have no direct access to a store constant primitive. */ if ((ts->val_type == TEMP_VAL_CONST && NEED_SYNC_ARG(0)) || ts->val_type == TEMP_VAL_MEM) { r~