]> git.ipfire.org Git - thirdparty/gcc.git/commit
bitint: Fix up handling of uninitialized mul/div/float cast operands [PR121127]
authorJakub Jelinek <jakub@redhat.com>
Wed, 6 Aug 2025 09:28:37 +0000 (11:28 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 6 Aug 2025 09:29:32 +0000 (11:29 +0200)
commitd175a6b119b8ab177ab9d9fb81dcac1794d18ad6
tree6afa36165c29cd03b0b5a8d6a6e07a23c0e22c77
parent4f2cd5a88838ce0af9f4d6425c55e702e44ae8d2
bitint: Fix up handling of uninitialized mul/div/float cast operands [PR121127]

handle_operand_addr (used for the cases where we use libgcc APIs, so
multiplication, division, modulo, casts of _BitInt to float/dfp) when it
sees default definition of an SSA_NAME which is not PARM_DECL (i.e.
uninitialized one) just allocates single uninitialized limb, there is no
need to waste more memory on it, it can just tell libgcc that it has
64-bit precision, not say 1024 bit etc.
Unfortunately, doing this runs into some asserts when we have a narrowing
cast of the uninitialized SSA_NAME (but still large/huge _BitInt).

The following patch fixes that by using a magic value in *prec_stored
for the uninitialized cases (0) and just don't do any *prec tweaks for
narrowing casts from that.  precs still needs to be maintained as before,
that one is used for big endian adjustment.

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

PR tree-optimization/121127
* gimple-lower-bitint.cc (bitint_large_huge::handle_operand_addr): For
uninitialized SSA_NAME, set *prec_stored to 0 rather than *prec.
Handle that case in narrowing casts.  If prec_stored is non-NULL,
set *prec_stored to prec_stored_val.

* gcc.dg/bitint-125.c: New test.
gcc/gimple-lower-bitint.cc
gcc/testsuite/gcc.dg/bitint-125.c [new file with mode: 0644]