From patchwork Wed Oct 3 18:07:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 148074 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp6797955lji; Wed, 3 Oct 2018 11:11:54 -0700 (PDT) X-Google-Smtp-Source: ACcGV60S52VzjvYfaESZkaUU7YvoA5MmS9UkM0CmyEnuR7pO7hpnO5Qi5R8lJ7mflEu5AOGvSP0a X-Received: by 2002:ac8:6119:: with SMTP id a25-v6mr2293147qtm.130.1538590314512; Wed, 03 Oct 2018 11:11:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538590314; cv=none; d=google.com; s=arc-20160816; b=dggzFvR3HvPKYROpDT2a9alFLuYhTXGJW9s4TpfiRbvES/eXIVUld28HLd0PXwCs/9 O3euOTux4mFJ1BS42bSYG3ldPH+QjJu396LQSlJeo3TqgagicTR+wBbE+42ToElFlG8b Mx5geAo/PmbliwsiM+VNtsWUnaE5NP1kRA7GVjt+qaIQqZZpQ8DmBEl9M1p51CX3kJeX gEdkPEsOgfaGwRm2KH2KgX41a1eNadDsnas7w6CVuy7jbWdSXMFE8zOcOSDYf248bdJF cpufzA6v9y0rm9Rw2NtFsl6bf2TgpngFwcXWhu10i7R8DWGogpdRFi5OJXpwKWXv7+Ji C4+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=odg7ZfMV79SrVzKzwTaTVznqxYz9qBXX7PFYNzpKD8U=; b=huxDl7wFdsJKy+qiTGT//d3aVjfKoBWLTPNPLCVXxh0LB4+F73dXpBhcwEkNxomjhH Q80tMG5KBBsIKaIJdeffqhG2NHZVcf1w6095wXeKlBhNJ1S2uHmQfo9MNy3k6yAOqEhw 9xnJN5mjDnxugeW70BhTpZLsGHHUeRtw7eou6dO/WQNEMZ6/vw2Yo8maEEJ5KkN78YB0 vYB2m5dbqCqnh8z1nVb9KyKjwOUs/9VkVjnBFBSqym65J0+ZhRps2Vo2aTzfUCFFh6nm y/NrVXCMkfXtDsDpHX2pQDfHzKnpk0xDWSpmYZ/8nt++ptMip/6xhcixuOVSqXCj6QpB COsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=HU0y4ynC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id y190-v6si1244236qka.39.2018.10.03.11.11.54 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 03 Oct 2018 11:11:54 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=HU0y4ynC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:51688 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7lco-0005qT-1j for patch@linaro.org; Wed, 03 Oct 2018 14:11:54 -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) 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-Received: by 2002:a9d:248:: with SMTP id 66-v6mr1437729otb.366.1538590037290; Wed, 03 Oct 2018 11:07:17 -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) 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 --- include/fpu/softfloat-macros.h | 7 ++++--- fpu/softfloat.c | 35 ++++++++++++++++++++++++++-------- 2 files changed, 31 insertions(+), 11 deletions(-) -- 2.17.1 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; @@ -658,8 +659,8 @@ static inline uint64_t div128To64(uint64_t n0, uint64_t n1, uint64_t d) } r0 -= m; - /* Return remainder in LSB */ - return (q1 << 32) | q0 | (r0 != 0); + *r = r0; + return (q1 << 32) | q0; } /*---------------------------------------------------------------------------- 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, FloatParts b, float_status *s) bool sign = a.sign ^ b.sign; if (a.cls == float_class_normal && b.cls == float_class_normal) { - uint64_t temp_lo, temp_hi; + uint64_t n0, n1, q, r; int exp = 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 normalization, + * 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 left + * by one (more), and the remainder must be shifted right by one. + */ if (a.frac < b.frac) { exp -= 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 = div128To64(temp_lo, temp_hi, b.frac); + q = 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 = q | (r != 0); a.sign = sign; a.exp = exp; return a; From patchwork Wed Oct 3 18:07:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 148073 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp6796297lji; Wed, 3 Oct 2018 11:10:23 -0700 (PDT) X-Google-Smtp-Source: ACcGV62KGO30etI4OKgSw4OdA7l7UqhgSzfOrpIafnetxZIcj9+oJ0IBwnsrgC07br05RA7RP7Oc X-Received: by 2002:ac8:25e9:: with SMTP id f38-v6mr1884269qtf.227.1538590223340; Wed, 03 Oct 2018 11:10:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538590223; cv=none; d=google.com; s=arc-20160816; b=TnxLe+FTLdU9dhuySZbzm3mRhWDDd3dBhlDsN+/LhoPp7yI+3+0RJ1z7RiGKrgZhOp 185sTx3DvxlsX0EJvDEqmX1/bWez0cicbF+77PUYhugZEXAp1wpwWN4q64nJI+LQKZn/ vnlNkNVj3zI1qAQRgcdNi3gvqT4GX3eY99c7LXLJ31Jbm6mtrAv0foFqpqKrruG4dEOq akbRGXzZygXf6DUu87yK2IP6XQmp7xLskteJyBpGop+/mOPsTKUUeu9ngqJ4YVF6RsYk Vl9GDAdLVG9aqJcAudIwOKc6nOBLSEZX3Tb7aEDVVdS6FV/n7OCkqULuhnUV0af9hTKG FCSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=g1slopZ4qkafsxJ+xoE1KW0cUVFz+tpfz7X9jI7y1Jo=; b=iRYQVPD/GNG/daTM5IPJ0f17vS+cuohXpGD++VIo+LFDroKqmHCyHFR4zGXYhSqQFr yDK4Hii84U/flRFPDUWs9ljK8OFQ0C2MnkZTmpJTOJn+ei+1xrkAtMnwMoiKjoc77tMV kVVTS22/88TDqUAkzvVMrUGVxT9fON3nvbLcR5+8Ab3rFfWgKhdsG8JK/1j71ET2wpvG raabIpVtwNFpbBNe+DdD28d9JISrfwcLugj9DqIExygAmN8Jtjpip3mOMROgE++X5cYy jBghtilSxIUf/zbekqTWcLqPSnWXzbWwb5Ji2FY9URy7NOYqRhklKr3GWOgwi1UlAq2j ghSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=RJRkHG6R; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id h205-v6si1340698qke.262.2018.10.03.11.10.23 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 03 Oct 2018 11:10:23 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=RJRkHG6R; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:51673 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7lbK-0004XC-Rp for patch@linaro.org; Wed, 03 Oct 2018 14:10:22 -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) 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-Received: by 2002:aca:3546:: with SMTP id c67-v6mr1366160oia.249.1538590039070; Wed, 03 Oct 2018 11:07:19 -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) 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The ISA has a 128/64-bit division instruction. Signed-off-by: Richard Henderson --- include/fpu/softfloat-macros.h | 6 ++++++ 1 file changed, 6 insertions(+) -- 2.17.1 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" : "=a"(q), "=d"(*r) : "0"(n0), "1"(n1), "rm"(d)); + return q; +#else uint64_t d0, d1, q0, q1, r1, r0, m; d0 = (uint32_t)d; @@ -661,6 +666,7 @@ static inline uint64_t udiv_qrnnd(uint64_t *r, uint64_t n1, *r = r0; return (q1 << 32) | q0; +#endif } /*---------------------------------------------------------------------------- From patchwork Wed Oct 3 18:07:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 148071 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp6795886lji; Wed, 3 Oct 2018 11:10:01 -0700 (PDT) X-Google-Smtp-Source: ACcGV63+7hLY8IOsEkejGUhX9Vx+cMZ88LYWsCTkmzUXamzqA5p8u715b3JwKCKkEd1D6svLJW+v X-Received: by 2002:a37:ec3:: with SMTP id 186-v6mr2105981qko.345.1538590201166; Wed, 03 Oct 2018 11:10:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538590201; cv=none; d=google.com; s=arc-20160816; b=vL30B12+yQQsO+nxpL0Yj2MT14E3rPTVb+5g9gEB+3rMqpZ/t4iyLy8A2jL4HP2YHB wqXBitGpT2x5fMurIkD0uQchFdUM6Ms9TWaZLI1j9jOfwJ5VGPi1LPJWlrfIcFeEPRXB TEGsXP3RDhAG9Adb2jJs5YRA21F5Ls93ijE7LWwQWqgc1uTImOpTaASvcSLL67cbMbgs tAthxc6zjmsDiym3k8a4VeoZO8z466qLZNmvJBl6vMWV03EiXyYsKNo8CbnhJokQqI4j DphKYvzA3Qx2wLgh8JYPpa+tLDSaQ42C223qUAHRWR4CgJOV7vg0v1zCGF3p1YuY/XEk i/Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=h/UUwuBsuOriHqYEE8QDml49uVKddhJm2wEnXLuAd8w=; b=NbFDSNOPZ2C/8t6a4kTDEI1c0vAXUhKMh1x0XNvCr9T6Uxy+wKg+Kf0lMf2PSVn7YC k5Ci9yl+ZOk9RxlVZV3+0XqHhVNGMwlZFRkZNvR6mW66Ue9OmtausYt/ra5xKbNwGdfp CvmiJHEVjDp6OOO+/O/74XdmPvyhPufB9Inbwn0SwcDkeDrtdIaqQ8lBafk75uwKyPCB LRxFfoQnp8s2jqiT1wKcqfM7cP3xwV8HK8cUeDHr/Hez2cOLF6pV8QYsMbFLRqMzuWSv l2eG9CjEZsxTogsJdU77bcHB/zPlyfElqx+wHeoSW4GCyXJ9NCc+fyypmsVNRr9tFOhp gJwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=c+qOS7iM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id u9-v6si139685qki.158.2018.10.03.11.10.00 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 03 Oct 2018 11:10:01 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=c+qOS7iM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:51669 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7lay-0004Sx-JE for patch@linaro.org; Wed, 03 Oct 2018 14:10:00 -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) 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-Received: by 2002:a9d:2949:: with SMTP id d67-v6mr1454754otb.205.1538590041000; Wed, 03 Oct 2018 11:07:21 -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) 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 --- include/fpu/softfloat-macros.h | 6 ++++++ 1 file changed, 6 insertions(+) -- 2.17.1 Reviewed-by: David Hildenbrand 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" : "=a"(q), "=d"(*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 = (unsigned __int128)n1 << 64 | n0; + asm("dlgr %0, %1" : "+r"(n) : "r"(d)); + *r = n >> 64; + return n; #else uint64_t d0, d1, q0, q1, r1, r0, m; From patchwork Wed Oct 3 18:07:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 148072 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp6795919lji; Wed, 3 Oct 2018 11:10:02 -0700 (PDT) X-Google-Smtp-Source: ACcGV62QDYnL6KVFIKvjOYctTxpGqHEm+nnueAtkWvUusgA37iVK18GKrHA+PD1P/mX9hJqoN6M0 X-Received: by 2002:ac8:2f86:: with SMTP id l6-v6mr2259576qta.83.1538590202392; Wed, 03 Oct 2018 11:10:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538590202; cv=none; d=google.com; s=arc-20160816; b=mY2WsL8Wa2WFnQTbirsB4teXpAIhcBFmH7aMH5mtUJjbk06MZuZbIBlzZ5qLn1eOQi 3YnbWp0UZzcsCkqO8wr7EZ/En0QBdR6/ggkOY4HUK35JA0OnFHWbhOrqb0hwZni7lZAa 6/TuaRg9bq0qqOl5521QFLbnV0ZIKqCA/F2URSRmkzKpnZHJHUHpJmKFnSHRTfa3AqQM nbfdX/hvFYHBfXSB25X38GnztycP4eVimXWtB4oCRnDEFMLcIXVlmkN21JI57rVQ2FWS F5sRml61NZe6XAQowCqDs2GdvAFJDKm8g9WTeraOY7ZBvNTXlHLgw0UaCDWVptRObX38 tmOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=7Fy5hUYquxIH5oDgQGI4lfGc1AXghgu5Y0CJkuKRgJg=; b=rvxBJ0h9YClRJacCgtn54y/z5xcfwHZXxHkqIAxPNmeul7ObjlOistegrnalWdfOWp 8wVglv6RufDSS81ISDpwxdoUlYNJ4xlsW+B+iYaRPgG5WtItlMdNhEyXG7FKBkq7Xaga k9gla+lhyk6tei1mSGbtwYyQv8j74bMSyPh18qDWPSO4lPahLE+vdHZqH/fJfrx2BkCh YVnnlQF9ZfvSA1jyk9g1fn9C8Ns9PLOtiFF2JDxYs0073i79QT2tzK7/D0mbGK6vzpkB 5QoSMhh6QYQ/EYk9WxPu+dFgZgXYaZBV0qtopC2IDRWUNQrbjg5JPQBNcKpKrq3YxAiu 0WRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ER3wpn9l; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id t19-v6si1360101qtt.278.2018.10.03.11.10.02 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 03 Oct 2018 11:10:02 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ER3wpn9l; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:51670 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7laz-0004U5-RN for patch@linaro.org; Wed, 03 Oct 2018 14:10:01 -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) 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-Received: by 2002:aca:da46:: with SMTP id r67-v6mr1224976oig.47.1538590042794; 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.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 --- include/fpu/softfloat-macros.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) -- 2.17.1 Reviewed-by: David Gibson 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 = 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" + : "=&r"(q1), "=r"(q2) + : "r"(n1), "r"(n0), "r"(d)); + r1 = -(q1 * d); /* low part of (n1<<64) - (q1 * d) */ + r2 = n0 - (q2 * d); + Q = q1 + q2; + R = r2 + r1; + if (R < r2 || R >= d) { /* overflow implies R > d */ + Q += 1; + R -= d; + } + *r = R; + return Q; #else uint64_t d0, d1, q0, q1, r1, r0, m;