Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.1/patches/2228413/?format=api
{ "id": 2228413, "url": "http://patchwork.ozlabs.org/api/1.1/patches/2228413/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260426134002.865628-28-richard.henderson@linaro.org/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/1.1/projects/14/?format=api", "name": "QEMU Development", "link_name": "qemu-devel", "list_id": "qemu-devel.nongnu.org", "list_email": "qemu-devel@nongnu.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20260426134002.865628-28-richard.henderson@linaro.org>", "date": "2026-04-26T13:39:04", "name": "[27/84] fpu: Drop parts_log2", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "0c481e5b8106eb98c3928ef519fe6c7cb08db82e", "submitter": { "id": 72104, "url": "http://patchwork.ozlabs.org/api/1.1/people/72104/?format=api", "name": "Richard Henderson", "email": "richard.henderson@linaro.org" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260426134002.865628-28-richard.henderson@linaro.org/mbox/", "series": [ { "id": 501533, "url": "http://patchwork.ozlabs.org/api/1.1/series/501533/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=501533", "date": "2026-04-26T13:38:37", "name": "fpu: Export some internals for targets", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/501533/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2228413/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2228413/checks/", "tags": {}, "headers": { "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256\n header.s=google header.b=dii9JTTs;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists1p.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)" ], "Received": [ "from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g3SgK0GjSz1yJ1\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 26 Apr 2026 23:47:25 +1000 (AEST)", "from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists1p.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wGzji-0008Ez-8h; Sun, 26 Apr 2026 09:41:26 -0400", "from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <richard.henderson@linaro.org>)\n id 1wGzjg-0008A5-PZ\n for qemu-devel@nongnu.org; Sun, 26 Apr 2026 09:41:24 -0400", "from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\n (Exim 4.90_1) (envelope-from <richard.henderson@linaro.org>)\n id 1wGzjc-0000C0-Tn\n for qemu-devel@nongnu.org; Sun, 26 Apr 2026 09:41:24 -0400", "by mail-pl1-x62e.google.com with SMTP id\n d9443c01a7336-2b24fdac394so90561695ad.3\n for <qemu-devel@nongnu.org>; Sun, 26 Apr 2026 06:41:20 -0700 (PDT)", "from stoup.. ([180.233.125.15]) by smtp.gmail.com with ESMTPSA id\n d9443c01a7336-2b5fab30f29sm277940375ad.68.2026.04.26.06.41.17\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Sun, 26 Apr 2026 06:41:18 -0700 (PDT)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=linaro.org; s=google; t=1777210879; x=1777815679; darn=nongnu.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=8iNu5b7hcfu4YD/ZRX99cYS8RApbvbMld9iCuftqu3w=;\n b=dii9JTTsiw0wgIvlg8T1XyPZQ/wjximJ1DgXF2un4Bcycq5zWf+e+G+1z//wIlJCua\n xd76qbcUBe5SB2CECxzitE5ZgXDmJUI3NY4iTcd8en9FK0eZk2IY0+I6EtHVAR/GYY2K\n Y4KMOmMcDIGcr5DWcnW9cqvDPm8DZ1XBXL2O6eX8V76+krLf9D9RALPMHg+3nQK3RKEy\n lZFASnVjq3LRnfJW1LhAsGwqEn/p5TqSEobhXyOK08EpoW9+1svt8dq7ehCSEQUtZxeO\n TuiahrHTAnNt1xKPA2FfswZg5dLCuAVnuVEdT2SBgv4DvgjzDNG6ebDq1PT6NqrdUNiw\n V+iw==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1777210879; x=1777815679;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=8iNu5b7hcfu4YD/ZRX99cYS8RApbvbMld9iCuftqu3w=;\n b=jVx6vVRcwtLGg9KoVhomqcHeKY4yYLN+SvmqKPvOysRav9aWQX9dkDURRsNTRh+tmP\n l44sVbdR4+ERR9Y/ICFtXXCXhruJoAKQVEBwUwMPOfvXAufoKQPmiZ5vSe1vIAc635DF\n SF9O42KLSNei9mlvWF9e+5pcMhEwVGRW4wCTMv67+0fvGhuVIgOPVvtDrGhzs/h3impL\n svuIBx8ul8agThplL6okdGYcnBW7A32RMu7ZzSibJI/FXZjK+KBcTRNRwDxNYYQVyGOk\n rK7XQb3ZkVGbuOFmrxThl9zt0JKA/DXRkttnKpB8IOuPgKW2FPjbwqwLqnHgV5MRZAdr\n HYUw==", "X-Gm-Message-State": "AOJu0YwGMOzJ9hGtJis/hdpbFjcxIEdxH07jUCFUkXQYOrR9qsjI762C\n OY0z/M0t/wNP6wVJ77yfruS6hvbj4RMAWO3WCIMau41WqTkcnjn7Nz7AS3jYM999fpztT/4WSf6\n 39e+sEzs=", "X-Gm-Gg": "AeBDiev5NPlhI+9jYJj7HwTxW6pooOVilNBqbPQjd4oW5cYwQ98gQMwxi/8rY+Z1Yie\n z8ik4j7AJ4i0K3O+BEaCTBzzc6UlNHJXse8Sw33KD0blCVbJFPVQL9KL9wBLIZvjiFKi8RJU1hB\n fymItIsnfgG30Nm4TGBkcKXraAgVfI62NWk24H+mvg50VjayMNWjG+oX1NZzcXzXqaOaXEKMToV\n hwKYsZTtC0mKpd30NpjKEKEByUKtJQCCbEcy8IX2j0oFpQynGU9X3RAyJ4meNdBOeu/+dUBnoQF\n wcrb0t5CXJBd1SzT0xZixpVCfeSIJs2mgGOBmhDOETQKH4qL5dlBb7kd+YNTNi6Mn5/NTU5+Oos\n wig5pm+bEIg20tjjSfunwedG3OTDHn0zOaj4VDSLBv7bmec7V8GTPdscQLTXgQPwn4Nr5Umjtpd\n W435tCuyaA2s/ZIsMxaMrgjjSl/m2LR05LAX/qmVzm", "X-Received": "by 2002:a17:903:2ac6:b0:2b2:549f:7d2b with SMTP id\n d9443c01a7336-2b5f9ee2f21mr401121385ad.11.1777210879382;\n Sun, 26 Apr 2026 06:41:19 -0700 (PDT)", "From": "Richard Henderson <richard.henderson@linaro.org>", "To": "qemu-devel@nongnu.org", "Cc": "qemu-arm@nongnu.org,\n\tqemu-s390x@nongnu.org", "Subject": "[PATCH 27/84] fpu: Drop parts_log2", "Date": "Sun, 26 Apr 2026 23:39:04 +1000", "Message-ID": "<20260426134002.865628-28-richard.henderson@linaro.org>", "X-Mailer": "git-send-email 2.43.0", "In-Reply-To": "<20260426134002.865628-1-richard.henderson@linaro.org>", "References": "<20260426134002.865628-1-richard.henderson@linaro.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Received-SPF": "pass client-ip=2607:f8b0:4864:20::62e;\n envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.google.com", "X-Spam_score_int": "-20", "X-Spam_score": "-2.1", "X-Spam_bar": "--", "X-Spam_report": "(-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,\n SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no", "X-Spam_action": "no action", "X-BeenThere": "qemu-devel@nongnu.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "qemu development <qemu-devel.nongnu.org>", "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>", "List-Archive": "<https://lists.nongnu.org/archive/html/qemu-devel>", "List-Post": "<mailto:qemu-devel@nongnu.org>", "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>", "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>", "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org", "Sender": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org" }, "content": "Use parts64_log2 at each call site.\n\nThat leaves parts128_log2 unused, so move the whole function back\nto softfloat.c and specialize for FloatParts64.\n\nSigned-off-by: Richard Henderson <richard.henderson@linaro.org>\n---\n fpu/softfloat.c | 133 +++++++++++++++++++++++++++++++++++---\n fpu/softfloat-parts.c.inc | 131 -------------------------------------\n 2 files changed, 125 insertions(+), 139 deletions(-)", "diff": "diff --git a/fpu/softfloat.c b/fpu/softfloat.c\nindex 3e6f2a152a..6a38d161f7 100644\n--- a/fpu/softfloat.c\n+++ b/fpu/softfloat.c\n@@ -779,12 +779,6 @@ static float128 QEMU_FLATTEN float128_pack_raw(const FloatParts128 *p)\n FloatParts128 *: parts128_##NAME, \\\n FloatParts256 *: parts256_##NAME)\n \n-static void parts64_log2(FloatParts64 *a, float_status *s, const FloatFmt *f);\n-static void parts128_log2(FloatParts128 *a, float_status *s, const FloatFmt *f);\n-\n-#define parts_log2(A, S, F) \\\n- PARTS_GENERIC_64_128(log2, A)(A, S, F)\n-\n /*\n * Helper functions for softfloat-parts.c.inc, per-size operations.\n */\n@@ -4851,12 +4845,135 @@ floatx80 floatx80_sqrt(floatx80 a, float_status *s)\n /*\n * log2\n */\n+\n+static void parts64_log2(FloatParts64 *a, float_status *s, const FloatFmt *fmt)\n+{\n+ uint64_t a0, a1, r, t, ign;\n+ int i, n, a_exp, f_exp;\n+\n+ if (unlikely(a->cls != float_class_normal)) {\n+ switch (a->cls) {\n+ case float_class_denormal:\n+ if (!a->sign) {\n+ /* -ve denormal will be InvalidOperation */\n+ float_raise(float_flag_input_denormal_used, s);\n+ }\n+ break;\n+ case float_class_snan:\n+ case float_class_qnan:\n+ parts64_return_nan(a, s);\n+ return;\n+ case float_class_zero:\n+ float_raise(float_flag_divbyzero, s);\n+ /* log2(0) = -inf */\n+ a->cls = float_class_inf;\n+ a->sign = 1;\n+ return;\n+ case float_class_inf:\n+ if (unlikely(a->sign)) {\n+ goto d_nan;\n+ }\n+ return;\n+ default:\n+ g_assert_not_reached();\n+ }\n+ }\n+ if (unlikely(a->sign)) {\n+ goto d_nan;\n+ }\n+\n+ a_exp = a->exp;\n+ f_exp = -1;\n+\n+ r = 0;\n+ t = DECOMPOSED_IMPLICIT_BIT;\n+ a0 = a->frac_hi;\n+ a1 = 0;\n+\n+ n = fmt->frac_size + 2;\n+ if (unlikely(a_exp == -1)) {\n+ /*\n+ * When a_exp == -1, we're computing the log2 of a value [0.5,1.0).\n+ * When the value is very close to 1.0, there are lots of 1's in\n+ * the msb parts of the fraction. At the end, when we subtract\n+ * this value from -1.0, we can see a catastrophic loss of precision,\n+ * as 0x800..000 - 0x7ff..ffx becomes 0x000..00y, leaving only the\n+ * bits of y in the final result. To minimize this, compute as many\n+ * digits as we can.\n+ * ??? This case needs another algorithm to avoid this.\n+ */\n+ n = fmt->frac_size * 2 + 2;\n+ /* Don't compute a value overlapping the sticky bit */\n+ n = MIN(n, 62);\n+ }\n+\n+ for (i = 0; i < n; i++) {\n+ if (a1) {\n+ mul128To256(a0, a1, a0, a1, &a0, &a1, &ign, &ign);\n+ } else if (a0 & 0xffffffffull) {\n+ mul64To128(a0, a0, &a0, &a1);\n+ } else if (a0 & ~DECOMPOSED_IMPLICIT_BIT) {\n+ a0 >>= 32;\n+ a0 *= a0;\n+ } else {\n+ goto exact;\n+ }\n+\n+ if (a0 & DECOMPOSED_IMPLICIT_BIT) {\n+ if (unlikely(a_exp == 0 && r == 0)) {\n+ /*\n+ * When a_exp == 0, we're computing the log2 of a value\n+ * [1.0,2.0). When the value is very close to 1.0, there\n+ * are lots of 0's in the msb parts of the fraction.\n+ * We need to compute more digits to produce a correct\n+ * result -- restart at the top of the fraction.\n+ * ??? This is likely to lose precision quickly, as for\n+ * float128; we may need another method.\n+ */\n+ f_exp -= i;\n+ t = r = DECOMPOSED_IMPLICIT_BIT;\n+ i = 0;\n+ } else {\n+ r |= t;\n+ }\n+ } else {\n+ add128(a0, a1, a0, a1, &a0, &a1);\n+ }\n+ t >>= 1;\n+ }\n+\n+ /* Set sticky for inexact. */\n+ r |= (a1 || a0 & ~DECOMPOSED_IMPLICIT_BIT);\n+\n+ exact:\n+ parts64_sint_to_float(a, a_exp, 0, s);\n+ if (r != 0) {\n+ FloatParts64 f = {\n+ .cls = float_class_normal, .frac = r\n+ };\n+ f.exp = f_exp - frac_normalize(&f);\n+\n+ if (a_exp < 0) {\n+ parts64_sub_normal(a, &f);\n+ } else if (a_exp > 0) {\n+ parts64_add_normal(a, &f);\n+ } else {\n+ *a = f;\n+ }\n+ }\n+ return;\n+\n+ d_nan:\n+ float_raise(float_flag_invalid, s);\n+ parts64_default_nan(a, s);\n+}\n+\n float32 float32_log2(float32 a, float_status *status)\n {\n FloatParts64 p;\n \n float32_unpack_canonical(&p, a, status);\n- parts_log2(&p, status, &float32_params);\n+ parts64_log2(&p, status, &float32_params);\n return float32_round_pack_canonical(&p, status);\n }\n \n@@ -4865,7 +4982,7 @@ float64 float64_log2(float64 a, float_status *status)\n FloatParts64 p;\n \n float64_unpack_canonical(&p, a, status);\n- parts_log2(&p, status, &float64_params);\n+ parts64_log2(&p, status, &float64_params);\n return float64_round_pack_canonical(&p, status);\n }\n \ndiff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc\nindex 8405cf29cd..5f27efd288 100644\n--- a/fpu/softfloat-parts.c.inc\n+++ b/fpu/softfloat-parts.c.inc\n@@ -1671,134 +1671,3 @@ static void partsN(scalbn)(FloatPartsN *a, int n, float_status *s)\n g_assert_not_reached();\n }\n }\n-\n-/*\n- * Return log2(A)\n- */\n-static void partsN(log2)(FloatPartsN *a, float_status *s, const FloatFmt *fmt)\n-{\n- uint64_t a0, a1, r, t, ign;\n- FloatPartsN f;\n- int i, n, a_exp, f_exp;\n-\n- if (unlikely(a->cls != float_class_normal)) {\n- switch (a->cls) {\n- case float_class_denormal:\n- if (!a->sign) {\n- /* -ve denormal will be InvalidOperation */\n- float_raise(float_flag_input_denormal_used, s);\n- }\n- break;\n- case float_class_snan:\n- case float_class_qnan:\n- partsN(return_nan)(a, s);\n- return;\n- case float_class_zero:\n- float_raise(float_flag_divbyzero, s);\n- /* log2(0) = -inf */\n- a->cls = float_class_inf;\n- a->sign = 1;\n- return;\n- case float_class_inf:\n- if (unlikely(a->sign)) {\n- goto d_nan;\n- }\n- return;\n- default:\n- g_assert_not_reached();\n- }\n- }\n- if (unlikely(a->sign)) {\n- goto d_nan;\n- }\n-\n- /* TODO: This algorithm looses bits too quickly for float128. */\n- g_assert(N == 64);\n-\n- a_exp = a->exp;\n- f_exp = -1;\n-\n- r = 0;\n- t = DECOMPOSED_IMPLICIT_BIT;\n- a0 = a->frac_hi;\n- a1 = 0;\n-\n- n = fmt->frac_size + 2;\n- if (unlikely(a_exp == -1)) {\n- /*\n- * When a_exp == -1, we're computing the log2 of a value [0.5,1.0).\n- * When the value is very close to 1.0, there are lots of 1's in\n- * the msb parts of the fraction. At the end, when we subtract\n- * this value from -1.0, we can see a catastrophic loss of precision,\n- * as 0x800..000 - 0x7ff..ffx becomes 0x000..00y, leaving only the\n- * bits of y in the final result. To minimize this, compute as many\n- * digits as we can.\n- * ??? This case needs another algorithm to avoid this.\n- */\n- n = fmt->frac_size * 2 + 2;\n- /* Don't compute a value overlapping the sticky bit */\n- n = MIN(n, 62);\n- }\n-\n- for (i = 0; i < n; i++) {\n- if (a1) {\n- mul128To256(a0, a1, a0, a1, &a0, &a1, &ign, &ign);\n- } else if (a0 & 0xffffffffull) {\n- mul64To128(a0, a0, &a0, &a1);\n- } else if (a0 & ~DECOMPOSED_IMPLICIT_BIT) {\n- a0 >>= 32;\n- a0 *= a0;\n- } else {\n- goto exact;\n- }\n-\n- if (a0 & DECOMPOSED_IMPLICIT_BIT) {\n- if (unlikely(a_exp == 0 && r == 0)) {\n- /*\n- * When a_exp == 0, we're computing the log2 of a value\n- * [1.0,2.0). When the value is very close to 1.0, there\n- * are lots of 0's in the msb parts of the fraction.\n- * We need to compute more digits to produce a correct\n- * result -- restart at the top of the fraction.\n- * ??? This is likely to lose precision quickly, as for\n- * float128; we may need another method.\n- */\n- f_exp -= i;\n- t = r = DECOMPOSED_IMPLICIT_BIT;\n- i = 0;\n- } else {\n- r |= t;\n- }\n- } else {\n- add128(a0, a1, a0, a1, &a0, &a1);\n- }\n- t >>= 1;\n- }\n-\n- /* Set sticky for inexact. */\n- r |= (a1 || a0 & ~DECOMPOSED_IMPLICIT_BIT);\n-\n- exact:\n- partsN(sint_to_float)(a, a_exp, 0, s);\n- if (r == 0) {\n- return;\n- }\n-\n- memset(&f, 0, sizeof(f));\n- f.cls = float_class_normal;\n- f.frac_hi = r;\n- f.exp = f_exp - frac_normalize(&f);\n-\n- if (a_exp < 0) {\n- partsN(sub_normal)(a, &f);\n- } else if (a_exp > 0) {\n- partsN(add_normal)(a, &f);\n- } else {\n- *a = f;\n- }\n- return;\n-\n- d_nan:\n- float_raise(float_flag_invalid, s);\n- partsN(default_nan)(a, s);\n-}\n", "prefixes": [ "27/84" ] }