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

--- Comment #3 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:9511b91c56f08b319b4a407608f85c96029ce7ce

commit r14-8941-g9511b91c56f08b319b4a407608f85c96029ce7ce
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Mon Feb 12 20:46:04 2024 +0100

    lower-bitint: Fix handle_cast when used e.g. in comparisons of precisions
multiple of limb_prec [PR113849]

    handle_cast handles the simple way all narrowing large/huge bitint to
    large/huge bitint conversions and also such widening conversions if we can
    assume that the most significant limb is processed using constant index
    and both lhs and rhs have same number of limbs.
    But, the condition whether we can rely on the most significant limb
    being processed using constant index is incorrect.
    For m_upwards_2limb it was correct (m_upwards_2limb then is the number
    of limbs handled by the loop, so if lhs_type has larger precision than
    that, it is handled with constant index), similarly if m_var_msb is set
    (on left shifts), it is never handled with constant idx.  But in other
    cases, like right shifts or non-equality comparisons, or bitquery
operations
    which operate from most significant to least significant limb, all those
    can handle even the most significant limb in a loop when lhs_type has
    precision which is a multiple of limb_prec.

    So, the following patch punts on the optimization in that case and goes for
    the conditionals in the loop for that case.

    2024-02-12  Jakub Jelinek  <ja...@redhat.com>

            PR tree-optimization/113849
            * gimple-lower-bitint.cc (bitint_large_huge::handle_cast): Don't
use
            fast path for widening casts where !m_upwards_2limb and lhs_type
            has precision which is a multiple of limb_prec.

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

Reply via email to