From: Ilya Leoshkevich <iii@linux.ibm.com>
To: Thomas Huth <thuth@redhat.com>,
Richard Henderson <richard.henderson@linaro.org>
Cc: David Hildenbrand <david@kernel.org>,
qemu-s390x@nongnu.org, qemu-devel@nongnu.org,
Ilya Leoshkevich <iii@linux.ibm.com>
Subject: [PATCH v3 3/5] fpu: Restrict parts_round_to_int_normal to target precision
Date: Thu, 29 Jan 2026 19:57:23 +0100 [thread overview]
Message-ID: <20260129190902.196262-4-iii@linux.ibm.com> (raw)
In-Reply-To: <20260129190902.196262-1-iii@linux.ibm.com>
Currently parts_round_to_int_normal() assumes that its input has just
been unpacked and therefore doesn't expect non-zero fraction bits past
target precision.
The upcoming DIVIDE TO INTEGER use cases needs it to support
calculations on intermediate values that utilize all fraction bits,
while at the same time restricting the result's precision to frac_size.
Delete the "All integral" check, because even though really large
values are always integer, their low fraction bits still need to be
truncated. For the same reason, make sure rnd_mask covers at least
fraction bits past target precision.
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
fpu/softfloat-parts.c.inc | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
index 5e0438fc0b7..93ed59626e5 100644
--- a/fpu/softfloat-parts.c.inc
+++ b/fpu/softfloat-parts.c.inc
@@ -1118,11 +1118,6 @@ static bool partsN(round_to_int_normal)(FloatPartsN *a, FloatRoundMode rmode,
return true;
}
- if (a->exp >= frac_size) {
- /* All integral */
- return false;
- }
-
if (N > 64 && a->exp < N - 64) {
/*
* Rounding is not in the low word -- shift lsb to bit 2,
@@ -1133,7 +1128,7 @@ static bool partsN(round_to_int_normal)(FloatPartsN *a, FloatRoundMode rmode,
frac_lsb = 1 << 2;
} else {
shift_adj = 0;
- frac_lsb = DECOMPOSED_IMPLICIT_BIT >> (a->exp & 63);
+ frac_lsb = DECOMPOSED_IMPLICIT_BIT >> MIN(a->exp, frac_size);
}
frac_lsbm1 = frac_lsb >> 1;
--
2.52.0
next prev parent reply other threads:[~2026-01-29 19:10 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-29 18:57 [PATCH v3 0/5] target/s390x: Implement DIVIDE TO INTEGER Ilya Leoshkevich
2026-01-29 18:57 ` [PATCH v3 1/5] target/s390x: Dump Floating-Point-Control Register Ilya Leoshkevich
2026-01-30 7:27 ` Thomas Huth
2026-01-29 18:57 ` [PATCH v3 2/5] target/s390x: Extract s390_get_bfp_rounding_mode() Ilya Leoshkevich
2026-01-30 7:30 ` Thomas Huth
2026-01-29 18:57 ` Ilya Leoshkevich [this message]
2026-02-02 6:16 ` [PATCH v3 3/5] fpu: Restrict parts_round_to_int_normal to target precision Richard Henderson
2026-01-29 18:57 ` [PATCH v3 4/5] target/s390x: Implement DIVIDE TO INTEGER Ilya Leoshkevich
2026-01-29 23:28 ` Ilya Leoshkevich
2026-02-04 6:01 ` Richard Henderson
2026-01-29 18:57 ` [PATCH v3 5/5] tests/tcg/s390x: Test " Ilya Leoshkevich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260129190902.196262-4-iii@linux.ibm.com \
--to=iii@linux.ibm.com \
--cc=david@kernel.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.