]> git.ipfire.org Git - thirdparty/gcc.git/commit
dfp: Further decimal_real_to_integer fixes [PR120631]
authorJakub Jelinek <jakub@redhat.com>
Thu, 19 Jun 2025 06:57:27 +0000 (08:57 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 19 Jun 2025 07:07:57 +0000 (09:07 +0200)
commite3cf9e55e394de211617333bbc3419c248d3e6b6
tree5e25c11d897ec49b9b34358765c77dd7872374c0
parent153160c3f59c01ab864726abce66b4c3a0f2d909
dfp: Further decimal_real_to_integer fixes [PR120631]

Unfortunately, the following further testcase shows that there aren't
problems only with very large precisions and large exponents, but pretty
much anything larger than 64-bits.  After all, before _BitInt support dfp
didn't even have {,unsigned }__int128 <-> _Decimal{32,64,128,64x} support,
and the testcase again shows some of the conversions yielding zeros.
While the pr120631.c test worked even without the earlier patch.

So, this patch assumes 64-bit precision at most is ok and for anything
larger it just uses exponent 0 and multiplies afterwards.

2025-06-19  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/120631
* dfp.cc (decimal_real_to_integer): Use result multiplication not just
when precision > 128 and dn.exponent > 19, but when precision > 64
and dn.exponent > 0.

* gcc.dg/dfp/bitint-10.c: New test.
* gcc.dg/dfp/pr120631.c: New test.

(cherry picked from commit e2eb9da5546b5e2fccb86586cda3beee8f69f5c9)
gcc/dfp.cc
gcc/testsuite/gcc.dg/dfp/bitint-10.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/dfp/pr120631.c [new file with mode: 0644]