From patchwork Mon Feb 25 19:41:40 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 223027 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5A26B2C0092 for ; Tue, 26 Feb 2013 07:06:04 +1100 (EST) Received: from localhost ([::1]:47940 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UA3xK-0003EO-7R for incoming@patchwork.ozlabs.org; Mon, 25 Feb 2013 14:43:22 -0500 Received: from eggs.gnu.org ([208.118.235.92]:58118) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UA3wW-0001C1-GL for qemu-devel@nongnu.org; Mon, 25 Feb 2013 14:42:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UA3wN-0001Tr-2s for qemu-devel@nongnu.org; Mon, 25 Feb 2013 14:42:32 -0500 Received: from mail-qe0-f42.google.com ([209.85.128.42]:51750) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UA3wM-0001Td-Uz for qemu-devel@nongnu.org; Mon, 25 Feb 2013 14:42:22 -0500 Received: by mail-qe0-f42.google.com with SMTP id f6so1507378qej.15 for ; Mon, 25 Feb 2013 11:42:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=3asfvQSFQwX4tSQskA4HDFrFWITKSTCYM2XahM51vKg=; b=L+0qfSYMgyG1puwqkrMadxZ+RYx2VLWxACX9jZLTzyJEf+TJJxhKE+Og2uatpk8jpG V5OixeyFewypcwRVQEC6d9ALdpKuieReTLKQDrof9eiHvcauHk1R6XwJggs6AScK43Zv bTVgs8IJxenTk01NMCq+JaF2DfbjFHrNgjlrGmxSQ/ECm69jVAB1lCwDCXKntcS0Vidn +baEBdrbK0iVE955tGZr3kU9xVSrRIhkrD6CoLadJatPk8OLLqBS8kVkGojEOdN1PNWn ANyvoxHCvlRjCHbtx4vWCtlyGQ9X6zGgHTrOoc5UaGBZbRYRcm5RH8UGrMaxj2bW3aAj hxHA== X-Received: by 10.224.178.77 with SMTP id bl13mr13209556qab.13.1361821342301; Mon, 25 Feb 2013 11:42:22 -0800 (PST) Received: from anchor.com (50-194-63-110-static.hfc.comcastbusiness.net. [50.194.63.110]) by mx.google.com with ESMTPS id g6sm18194051qav.6.2013.02.25.11.42.20 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 25 Feb 2013 11:42:21 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 25 Feb 2013 11:41:40 -0800 Message-Id: <1361821300-10226-4-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1361821300-10226-1-git-send-email-rth@twiddle.net> References: <1361821300-10226-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.128.42 Cc: Anthony Liguori , Alexander Graf Subject: [Qemu-devel] [PATCH v3 3/3] target-ppc: Fix SUBFE carry X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org While ~T0+T1+CF = T1-T0+CF-1 is true for the low 32-bits, it does not produce the correct carry-out to bit 33. Do exactly what the manual says. Cc: Alexander Graf Signed-off-by: Richard Henderson --- target-ppc/translate.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/target-ppc/translate.c b/target-ppc/translate.c index f886441..80d5366 100644 --- a/target-ppc/translate.c +++ b/target-ppc/translate.c @@ -1120,14 +1120,15 @@ static inline void gen_op_arith_subf(DisasContext *ctx, TCGv ret, TCGv arg1, } if (add_ca) { - /* dest = ~arg1 + arg2 + ca = arg2 - arg1 + ca - 1. */ + /* dest = ~arg1 + arg2 + ca. */ if (compute_ca) { - TCGv zero; - tcg_gen_subi_tl(cpu_ca, cpu_ca, 1); + TCGv zero, inv1 = tcg_temp_new(); + tcg_gen_not_tl(inv1, arg1); zero = tcg_const_tl(0); tcg_gen_add2_tl(t0, cpu_ca, arg2, zero, cpu_ca, zero); - tcg_gen_sub2_tl(t0, cpu_ca, t0, cpu_ca, arg1, zero); + tcg_gen_add2_tl(t0, cpu_ca, t0, cpu_ca, inv1, zero); tcg_temp_free(zero); + tcg_temp_free(inv1); } else { tcg_gen_sub_tl(t0, arg2, arg1); tcg_gen_add_tl(t0, t0, cpu_ca);