From nobody Fri May 3 05:54:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1538590285109207.38247152166332; Wed, 3 Oct 2018 11:11:25 -0700 (PDT) Received: from localhost ([::1]:51685 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7lcJ-0005HJ-NW for importer@patchew.org; Wed, 03 Oct 2018 14:11:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55402) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7lYf-0002f4-VF for qemu-devel@nongnu.org; Wed, 03 Oct 2018 14:07:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g7lYb-0005AR-P0 for qemu-devel@nongnu.org; Wed, 03 Oct 2018 14:07:37 -0400 Received: from mail-ot1-x32a.google.com ([2607:f8b0:4864:20::32a]:32976) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g7lYa-00042u-7A for qemu-devel@nongnu.org; Wed, 03 Oct 2018 14:07:33 -0400 Received: by mail-ot1-x32a.google.com with SMTP id q50so2343837otd.0 for ; Wed, 03 Oct 2018 11:07:18 -0700 (PDT) Received: from cloudburst.twiddle.net ([187.217.227.243]) by smtp.gmail.com with ESMTPSA id f84-v6sm677709oia.44.2018.10.03.11.07.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 Oct 2018 11:07:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=odg7ZfMV79SrVzKzwTaTVznqxYz9qBXX7PFYNzpKD8U=; b=HU0y4ynCdHuYigSfxaPUHPiEujR0c7zDFQ0XKsBbxaRgCjHE4/aFXwYDDN+HvL97Sx ay5V44U6GsPSHtux6LQAgoX2IueihVhe9QVj5t/+wUae9Igum6D8B0Nfc5DrlEoO6mCE P9i5DRxzQIRrjuPHmAl5dISc9DKULYcynVUA8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=odg7ZfMV79SrVzKzwTaTVznqxYz9qBXX7PFYNzpKD8U=; b=Gxg8Xy8jX3iiAcgn7gQZr1IMrwATpAz20k9gN1j2knDmtrsaElm3DHLgu8lfiZMItM tHHp3RiDnFRGVyBY1ZbUocu8oe/cxPZY+V8tbK3OcbCXvCjstP/a3flCnpBRf72QyG6n SfMC0+IUcEPKdPDlrK+L4dFXH1Rm8gfCDVUunyB4t5f7vwEKXNNhedqw6qzO6hTJj/EM zTlJppPohG+OpbNJ/S2b623DDCfoLSphM1hlmtlhWqGg1O1vaDqJlP3TkH3K8ZPmhp1c /TdbBCyBeB788xit6c+5IvHiLaFKekprMhhLl2gjou9Zj4SxqS7vu7k3DjrGOoN8MfOl DVzg== X-Gm-Message-State: ABuFfoiadNQbLU/qlVO9zzwWlrYvrTM/zezgUTW+960KXMyrqIAOiZ5i HLZ3jtrzaJE4UP+AOba4ZzTNuteInwYnRg== X-Google-Smtp-Source: ACcGV63B8u1AEx4wmhCkflkOX1ASH3PBdmyhEZ/fRYqsaI0oW4OTGQo62MWSSqmzGWaW7S1RqolGNA== X-Received: by 2002:a9d:248:: with SMTP id 66-v6mr1437729otb.366.1538590037290; Wed, 03 Oct 2018 11:07:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 3 Oct 2018 13:07:08 -0500 Message-Id: <20181003180711.19335-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181003180711.19335-1-richard.henderson@linaro.org> References: <20181003180711.19335-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::32a Subject: [Qemu-devel] [PATCH v2 1/4] softfloat: Fix division X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: cota@braap.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The __udiv_qrnnd primitive that we nicked from gmp requires its inputs to be normalized. We were not doing that. Because the inputs are nearly normalized already, finishing that is trivial. Replace div128to64 with a "proper" udiv_qrnnd, so that this remains a reusable primitive. Fixes: cf07323d494 Fixes: https://bugs.launchpad.net/qemu/+bug/1793119 Signed-off-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e Tested-by: Emilio G. Cota --- include/fpu/softfloat-macros.h | 7 ++++--- fpu/softfloat.c | 35 ++++++++++++++++++++++++++-------- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/include/fpu/softfloat-macros.h b/include/fpu/softfloat-macros.h index edc682139e..03312471b2 100644 --- a/include/fpu/softfloat-macros.h +++ b/include/fpu/softfloat-macros.h @@ -619,7 +619,8 @@ static inline uint64_t estimateDiv128To64(uint64_t a0, = uint64_t a1, uint64_t b) * * Licensed under the GPLv2/LGPLv3 */ -static inline uint64_t div128To64(uint64_t n0, uint64_t n1, uint64_t d) +static inline uint64_t udiv_qrnnd(uint64_t *r, uint64_t n1, + uint64_t n0, uint64_t d) { uint64_t d0, d1, q0, q1, r1, r0, m; =20 @@ -658,8 +659,8 @@ static inline uint64_t div128To64(uint64_t n0, uint64_t= n1, uint64_t d) } r0 -=3D m; =20 - /* Return remainder in LSB */ - return (q1 << 32) | q0 | (r0 !=3D 0); + *r =3D r0; + return (q1 << 32) | q0; } =20 /*------------------------------------------------------------------------= ---- diff --git a/fpu/softfloat.c b/fpu/softfloat.c index a06b6ef7e4..97ef66d570 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -1112,19 +1112,38 @@ static FloatParts div_floats(FloatParts a, FloatPar= ts b, float_status *s) bool sign =3D a.sign ^ b.sign; =20 if (a.cls =3D=3D float_class_normal && b.cls =3D=3D float_class_normal= ) { - uint64_t temp_lo, temp_hi; + uint64_t n0, n1, q, r; int exp =3D a.exp - b.exp; + + /* + * We want a 2*N / N-bit division to produce exactly an N-bit + * result, so that we do not lose any precision and so that we + * do not have to renormalize afterward. If A.frac < B.frac, + * then division would produce an (N-1)-bit result; shift A left + * by one to produce the an N-bit result, and decrement the + * exponent to match. + * + * The udiv_qrnnd algorithm that we're using requires normalizatio= n, + * i.e. the msb of the denominator must be set. Since we know that + * DECOMPOSED_BINARY_POINT is msb-1, the inputs must be shifted le= ft + * by one (more), and the remainder must be shifted right by one. + */ if (a.frac < b.frac) { exp -=3D 1; - shortShift128Left(0, a.frac, DECOMPOSED_BINARY_POINT + 1, - &temp_hi, &temp_lo); + shortShift128Left(0, a.frac, DECOMPOSED_BINARY_POINT + 2, &n1,= &n0); } else { - shortShift128Left(0, a.frac, DECOMPOSED_BINARY_POINT, - &temp_hi, &temp_lo); + shortShift128Left(0, a.frac, DECOMPOSED_BINARY_POINT + 1, &n1,= &n0); } - /* LSB of quot is set if inexact which roundandpack will use - * to set flags. Yet again we re-use a for the result */ - a.frac =3D div128To64(temp_lo, temp_hi, b.frac); + q =3D udiv_qrnnd(&r, n1, n0, b.frac << 1); + + /* + * Set lsb if there is a remainder, to set inexact. + * As mentioned above, to find the actual value of the remainder we + * would need to shift right, but (1) we are only concerned about + * non-zero-ness, and (2) the remainder will always be even because + * both inputs to the division primitive are even. + */ + a.frac =3D q | (r !=3D 0); a.sign =3D sign; a.exp =3D exp; return a; --=20 2.17.1 From nobody Fri May 3 05:54:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1538590282505452.324411593076; Wed, 3 Oct 2018 11:11:22 -0700 (PDT) Received: from localhost ([::1]:51683 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7lcH-0005GB-4b for importer@patchew.org; Wed, 03 Oct 2018 14:11:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55403) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7lYf-0002f5-VH for qemu-devel@nongnu.org; Wed, 03 Oct 2018 14:07:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g7lYb-0005Am-Ta for qemu-devel@nongnu.org; Wed, 03 Oct 2018 14:07:37 -0400 Received: from mail-oi1-x230.google.com ([2607:f8b0:4864:20::230]:43579) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g7lYb-000478-KP for qemu-devel@nongnu.org; Wed, 03 Oct 2018 14:07:33 -0400 Received: by mail-oi1-x230.google.com with SMTP id s69-v6so5288521oie.10 for ; Wed, 03 Oct 2018 11:07:20 -0700 (PDT) Received: from cloudburst.twiddle.net ([187.217.227.243]) by smtp.gmail.com with ESMTPSA id f84-v6sm677709oia.44.2018.10.03.11.07.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 Oct 2018 11:07:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=g1slopZ4qkafsxJ+xoE1KW0cUVFz+tpfz7X9jI7y1Jo=; b=RJRkHG6R1Ihk37M6a2dBUc9Iz39O3K8sRBWf6c0wGk8kwT2W4ZHgSXkZrD/09VpMlY 08+N+Q6VowGi/17l19gh2NtkG7f3yOmTRjVhEHcuE7HnUISugSkhp6QU3ogdjTbL0c7K dY5n34Rd2BfM/9Z5KHe6qqn9I0PngRJG1vzkw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=g1slopZ4qkafsxJ+xoE1KW0cUVFz+tpfz7X9jI7y1Jo=; b=HQ8scOStwH5xUtd8FY25RVGSGRxZXLTlr0xfWt3s4UG8EVnJe4haO5K3LUrpLK4wa4 XZ+WOckNt3Zt7eoFgv8Rd4POFB5ZDxQOnwDw/mV312COW7ortn3NiNuldh/XZgvRBizA ROhV2giDS065+N+3YtKU8TGQ//10a3xbLnIJUTX0AM8PJ4S7MC9uA0R696spdqYis30Y di2LS+m1o7FY9/iQoc+f7LmkeFpj6SJ4awzsJGLWWh906kCcBZVEiUkOiYcoa9VjLlH9 chve7uBWp3PTI5d0GMpjCEhH5PVeEPkKTTjkomWytcMeKvIBy5J5ERxmCyuEqF0PSOj+ fkTQ== X-Gm-Message-State: ABuFfohDZb2QK3HfG/Tzqp7DiNcbsTBoUIpNbX2PLN+6Uedym9mhiXUd bNQ+SumYhpZ4NDuvOqE0IkF+n48T0iLckA== X-Google-Smtp-Source: ACcGV63I0urqnWrKfIJvsyHonfD8Ak0eEjbh/cE+2kmuhVw8LtaGJCkiQXtOWZ4gecTuy/z+RqG1PA== X-Received: by 2002:aca:3546:: with SMTP id c67-v6mr1366160oia.249.1538590039070; Wed, 03 Oct 2018 11:07:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 3 Oct 2018 13:07:09 -0500 Message-Id: <20181003180711.19335-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181003180711.19335-1-richard.henderson@linaro.org> References: <20181003180711.19335-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::230 Subject: [Qemu-devel] [PATCH v2 2/4] softfloat: Specialize udiv_qrnnd for x86_64 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: cota@braap.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The ISA has a 128/64-bit division instruction. Signed-off-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e Tested-by: Emilio G. Cota --- include/fpu/softfloat-macros.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/fpu/softfloat-macros.h b/include/fpu/softfloat-macros.h index 03312471b2..6d58615709 100644 --- a/include/fpu/softfloat-macros.h +++ b/include/fpu/softfloat-macros.h @@ -622,6 +622,11 @@ static inline uint64_t estimateDiv128To64(uint64_t a0,= uint64_t a1, uint64_t b) static inline uint64_t udiv_qrnnd(uint64_t *r, uint64_t n1, uint64_t n0, uint64_t d) { +#if defined(__x86_64__) + uint64_t q; + asm("divq %4" : "=3Da"(q), "=3Dd"(*r) : "0"(n0), "1"(n1), "rm"(d)); + return q; +#else uint64_t d0, d1, q0, q1, r1, r0, m; =20 d0 =3D (uint32_t)d; @@ -661,6 +666,7 @@ static inline uint64_t udiv_qrnnd(uint64_t *r, uint64_t= n1, =20 *r =3D r0; return (q1 << 32) | q0; +#endif } =20 /*------------------------------------------------------------------------= ---- --=20 2.17.1 From nobody Fri May 3 05:54:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1538590167596525.5727796336494; Wed, 3 Oct 2018 11:09:27 -0700 (PDT) Received: from localhost ([::1]:51665 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7laL-0003cY-F3 for importer@patchew.org; Wed, 03 Oct 2018 14:09:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55410) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7lYg-0002f7-0a for qemu-devel@nongnu.org; Wed, 03 Oct 2018 14:07:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g7lYb-0005B6-VJ for qemu-devel@nongnu.org; Wed, 03 Oct 2018 14:07:37 -0400 Received: from mail-ot1-x336.google.com ([2607:f8b0:4864:20::336]:43141) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g7lYb-0004DB-K7 for qemu-devel@nongnu.org; Wed, 03 Oct 2018 14:07:33 -0400 Received: by mail-ot1-x336.google.com with SMTP id e21-v6so6482817otk.10 for ; Wed, 03 Oct 2018 11:07:22 -0700 (PDT) Received: from cloudburst.twiddle.net ([187.217.227.243]) by smtp.gmail.com with ESMTPSA id f84-v6sm677709oia.44.2018.10.03.11.07.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 Oct 2018 11:07:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=h/UUwuBsuOriHqYEE8QDml49uVKddhJm2wEnXLuAd8w=; b=c+qOS7iMYs4GdZYTobija7byLZwmi6Hjk3I/4F1eS9Om90+goxLr96xSMHxfdhcHzj EENVe5rKI+8+fVGfzqTFhQONArOWeZrmJl3VIUKsgfBdY6pnovPfao4vojDknkl8SoVf cZKWdegIYP9FOffp+HmVSkv0c3hQLRKmvHtck= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=h/UUwuBsuOriHqYEE8QDml49uVKddhJm2wEnXLuAd8w=; b=N4pKEoJtZHQa0M/xCowWBWGGxerDIIufbW688Ju22R3MOu1KJ7YRopUsYvFOlqGU7Q N1KXSjj65BIiZ/0HTL2J1Mkue2Ly7h0EfLCiBqmxrKusnIKGNYY1mNVs/KDVO868HGAj xaoR202OWbpaBYqFNRmDK/vEuF7E4MgHHp+m2DP/QeaUA10WOhAeAK4FlBxfPpgfeyoS TMumon9NSkh7OkpSeg8WwdV4U5gMkO3plG8gZE6ecTvJMDYaEkiUs9x3RiOJ5uqgyOm6 qMoljiByJXCKZ/aJo1QgSu2ugBBYBW1jnlL+Nooxr4FpWIEXNK9m0URft3E8b8eaN9h5 QcLw== X-Gm-Message-State: ABuFfogwzqbmXoohPbXF0an4fef8N02wGU5Gn++N0ZQK8rLI5RDBRwm5 zK4C6VMOFVfhaI5vPFfc7gV3UplOl6nxUQ== X-Google-Smtp-Source: ACcGV60Vw2Ew0eUkdE3/1EDO+33dayMpdbAhSXQwXdz269OjmYk98zd9jZDu8ZWD8OWXB8FkJ0LNPA== X-Received: by 2002:a9d:2949:: with SMTP id d67-v6mr1454754otb.205.1538590041000; Wed, 03 Oct 2018 11:07:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 3 Oct 2018 13:07:10 -0500 Message-Id: <20181003180711.19335-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181003180711.19335-1-richard.henderson@linaro.org> References: <20181003180711.19335-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::336 Subject: [Qemu-devel] [PATCH v2 3/4] softfloat: Specialize udiv_qrnnd for s390x X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Hildenbrand , qemu-s390x@nongnu.org, cota@braap.org, alex.bennee@linaro.org, Cornelia Huck Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The ISA has a 128/64-bit division instruction. Cc: qemu-s390x@nongnu.org Cc: Cornelia Huck Cc: David Hildenbrand Signed-off-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e Reviewed-by: David Hildenbrand Tested-by: Alex Benn=C3=A9e Tested-by: Emilio G. Cota --- include/fpu/softfloat-macros.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/fpu/softfloat-macros.h b/include/fpu/softfloat-macros.h index 6d58615709..e702607b43 100644 --- a/include/fpu/softfloat-macros.h +++ b/include/fpu/softfloat-macros.h @@ -626,6 +626,12 @@ static inline uint64_t udiv_qrnnd(uint64_t *r, uint64_= t n1, uint64_t q; asm("divq %4" : "=3Da"(q), "=3Dd"(*r) : "0"(n0), "1"(n1), "rm"(d)); return q; +#elif defined(__s390x__) + /* Need to use a TImode type to get an even register pair for DLGR. */ + unsigned __int128 n =3D (unsigned __int128)n1 << 64 | n0; + asm("dlgr %0, %1" : "+r"(n) : "r"(d)); + *r =3D n >> 64; + return n; #else uint64_t d0, d1, q0, q1, r1, r0, m; =20 --=20 2.17.1 From nobody Fri May 3 05:54:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1538590168219653.7641877798515; Wed, 3 Oct 2018 11:09:28 -0700 (PDT) Received: from localhost ([::1]:51667 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7laL-0003dy-TL for importer@patchew.org; Wed, 03 Oct 2018 14:09:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55415) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7lYg-0002fA-2I for qemu-devel@nongnu.org; Wed, 03 Oct 2018 14:07:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g7lYc-0005Dp-DZ for qemu-devel@nongnu.org; Wed, 03 Oct 2018 14:07:37 -0400 Received: from mail-oi1-x241.google.com ([2607:f8b0:4864:20::241]:35532) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g7lYc-0004Hk-4W for qemu-devel@nongnu.org; Wed, 03 Oct 2018 14:07:34 -0400 Received: by mail-oi1-x241.google.com with SMTP id 22-v6so4321398oiz.2 for ; Wed, 03 Oct 2018 11:07:23 -0700 (PDT) Received: from cloudburst.twiddle.net ([187.217.227.243]) by smtp.gmail.com with ESMTPSA id f84-v6sm677709oia.44.2018.10.03.11.07.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 Oct 2018 11:07:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7Fy5hUYquxIH5oDgQGI4lfGc1AXghgu5Y0CJkuKRgJg=; b=ER3wpn9lv816JVXNK/qG3q+RNGJsKn/JEI5vPs3xmGl6jnZNBhjOXK1d2QZQvx9vK9 3pthf/wolmzRhLUbUzquxJf/W7AcnftmQK9EpClEWDOCyeXp+xVA2vL4iqCC6pkABQpo WYokLlFx6YFCnUBBys5rFlPQ9DNGhJZOkWSQk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7Fy5hUYquxIH5oDgQGI4lfGc1AXghgu5Y0CJkuKRgJg=; b=cCxaSoJpcJ/zAGyn1lcRg+PRGei6wQZTs1d/AdMdYazRLgSmoTgxhMrKUSPVETPyRk dnCwkibkqcAvX7xeHYQL21cKAP6stt/yyKEHLdzhxrMxqZW01J93y45tUhD82uHv6Sri b0BhCak9QdRMhuJ741Um2WxtW9fPnP/4QERx6k1b7v1NPlasqjWGgQlnbPeiT6vW7yHD VW1+WJ4Cal/IRc8g6G9xs0GKU43WjFYzOeYlk28tTUW2KUrnlWyPA+kRikt4YneKbAcW b6hCsWj4i1oww6INhqI4o5/ApaU5dN8oSgEIB6naEgAKG3RZ5l/OXDVanu9kd6KW0r94 OFgg== X-Gm-Message-State: ABuFfojs4FEpX4oqUU+U9/oHlMvLUitouwD6nDV2qk5ysCdP8FvzsWsv jZazhjGL/NNH7mYtT/Kgk3NiodfvoGGyBA== X-Google-Smtp-Source: ACcGV610X0lf+fgGaI3XOTjEBFzh5emLFFt8VEDNsBX55HJQhBOAbgXUExCTqfPojtyeL3ePqOA0zQ== X-Received: by 2002:aca:da46:: with SMTP id r67-v6mr1224976oig.47.1538590042794; Wed, 03 Oct 2018 11:07:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 3 Oct 2018 13:07:11 -0500 Message-Id: <20181003180711.19335-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181003180711.19335-1-richard.henderson@linaro.org> References: <20181003180711.19335-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::241 Subject: [Qemu-devel] [PATCH v2 4/4] softfloat: Specialize udiv_qrnnd for ppc64 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-ppc@nongnu.org, cota@braap.org, alex.bennee@linaro.org, Alexander Graf , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The ISA has a 128/64-bit division instruction, though it assumes the low 64-bits of the numerator are 0, and so requires a bit more fixup than a full 128-bit division insn. Cc: qemu-ppc@nongnu.org Cc: Alexander Graf Cc: David Gibson Signed-off-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e Reviewed-by: David Gibson Tested-by: Alex Benn=C3=A9e Tested-by: Emilio G. Cota --- include/fpu/softfloat-macros.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/fpu/softfloat-macros.h b/include/fpu/softfloat-macros.h index e702607b43..001bf4f23c 100644 --- a/include/fpu/softfloat-macros.h +++ b/include/fpu/softfloat-macros.h @@ -632,6 +632,22 @@ static inline uint64_t udiv_qrnnd(uint64_t *r, uint64_= t n1, asm("dlgr %0, %1" : "+r"(n) : "r"(d)); *r =3D n >> 64; return n; +#elif defined(_ARCH_PPC64) + /* From Power ISA 3.0B, programming note for divdeu. */ + uint64_t q1, q2, Q, r1, r2, R; + asm("divdeu %0,%2,%4; divdu %1,%3,%4" + : "=3D&r"(q1), "=3Dr"(q2) + : "r"(n1), "r"(n0), "r"(d)); + r1 =3D -(q1 * d); /* low part of (n1<<64) - (q1 * d) */ + r2 =3D n0 - (q2 * d); + Q =3D q1 + q2; + R =3D r2 + r1; + if (R < r2 || R >=3D d) { /* overflow implies R > d */ + Q +=3D 1; + R -=3D d; + } + *r =3D R; + return Q; #else uint64_t d0, d1, q0, q1, r1, r0, m; =20 --=20 2.17.1