From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40933) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cAFGb-000706-Qn for qemu-devel@nongnu.org; Fri, 25 Nov 2016 07:06:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cAFGa-0005lr-W6 for qemu-devel@nongnu.org; Fri, 25 Nov 2016 07:06:09 -0500 Received: from mail-yw0-x243.google.com ([2607:f8b0:4002:c05::243]:36270) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cAFGa-0005lU-Ry for qemu-devel@nongnu.org; Fri, 25 Nov 2016 07:06:08 -0500 Received: by mail-yw0-x243.google.com with SMTP id r204so3293069ywb.3 for ; Fri, 25 Nov 2016 04:06:08 -0800 (PST) Sender: Richard Henderson References: <1480044704-5805-1-git-send-email-jinguojie@loongson.cn> <1480044704-5805-12-git-send-email-jinguojie@loongson.cn> From: Richard Henderson Message-ID: <088324fc-5cfd-57d7-da25-6508734fa77e@twiddle.net> Date: Fri, 25 Nov 2016 13:06:01 +0100 MIME-Version: 1.0 In-Reply-To: <1480044704-5805-12-git-send-email-jinguojie@loongson.cn> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v3 11/11] tcg-mips: Adjust condition functions for mips64 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jin Guojie , qemu-devel@nongnu.org Cc: Aurelien Jarno , James Hogan On 11/25/2016 04:31 AM, Jin Guojie wrote: > 32-bit condition functions(like brcond_i32) should only > compare the low half parts of two 64-bit host registers. > However, MIPS64 does not have distinct instruction for > such operation. The operands should be sign extended > to fit the case. > > Gcc handles 32-bit comparison in the same way, as the > following example shows: > > [a.c] > main() > { > long a = 0xcccccccc; > long b = 0xdddddddd; > int c = (int)a > (int)b; > } This problem is why opcodes like OPC_INDEX_extrl_i64_i32 OPC_INDEX_extrh_i64_i32 OPC_INDEX_ext_i32_i64 OPC_INDEX_extu_i32_i64 exist. The intention is to keep 32-bit values in their sign-extended form, exactly as the mips hardware manual requires. At which point all 32-bit opcodes (ADDIU, SLL, etc) will preserve the 32-bit sign extension property. So you *should* never see a 32-bit comparison input that is not already sign-extended. A more appropriate gcc example would be $ cat z.c int foo(int a, int b) { return a > b; } $ mips64-linux-gcc -mabi=64 -O -S z.c $ cat z.s ... jr $31 slt $2,$5,$4 ... If you require this patch for getting correct results, then you have found a bug that needs to be fixed elsewhere. Can you describe the problem that you saw? r~