https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113361

--- Comment #1 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>:

https://gcc.gnu.org/g:f77a87982db60baa047b489ee4fea58b190503fb

commit r14-7224-gf77a87982db60baa047b489ee4fea58b190503fb
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Sat Jan 13 11:29:15 2024 +0100

    lower-bitint: Fix up handle_operand_addr INTEGER_CST handling [PR113361]

    As the testcase shows, the INTEGER_CST handling in handle_operand_addr
    (i.e. what is used when passing address of an integer to a bitint library
    routine) wasn't correct.  If the minimum precision to represent an
    INTEGER_CST is smaller or equal to limb_prec, the code correctly uses
    m_limb_type; if the minimum precision of a _BitInt INTEGER_CST is large
    enough such that the bitint is middle, large or huge, everything is fine
    too.  But the code wasn't handling correctly e.g. __int128 constants which
    need more than limb_prec bits or _BitInt constants which on the
architecture
    are considered small (say have DImode limb_mode, TImode abi_limb_mode and
    for [65, 128] bits use TImode scalar like the proposed aarch64 patch).
    Best would be to use an array of 2/3/4 limbs in that case, but we'd need to
    convert the INTEGER_CST to a CONSTRUCTOR in the right endianity etc.,
    so the code was using mid_min_prec to enforce a middle _BitInt precision.
    Except that mid_min_prec can be 0 and not computed yet, or it doesn't have
    to be the smallest middle _BitInt precision, just the smallest so far
    encountered.  So, on the testcase one possibility was that it used
precision
    65 from mid_min_prec, even when the INTEGER_CST actually needed larger
    minimum precision (96 bits at least), or crashed when mid_min_prec was 0.

    The patch fixes it in 2 hunks, the first makes sure we actually try to
    create a BITINT_TYPE for the > limb_prec cases like __int128, and the
second
    instead of using mid_min_prec attempts to increase mp precision until it
    isn't small anymore.

    2024-01-13  Jakub Jelinek  <ja...@redhat.com>

            PR tree-optimization/113361
            * gimple-lower-bitint.cc (bitint_large_huge::handle_operand_addr):
            Fix up determination of the type for > limb_prec constants.

            * gcc.dg/torture/bitint-47.c: New test.

Reply via email to