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

--- Comment #2 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:364332658ef790d09d250db39c5b13e27c3543f1

commit r14-6042-g364332658ef790d09d250db39c5b13e27c3543f1
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Fri Dec 1 09:25:45 2023 +0100

    lower-bitint: Fix _BitInt .{ADD,SUB}_OVERFLOW lowering [PR112750]

    The .{ADD,SUB}_OVERFLOW lowering is implemented by performing normal
    addition/subtraction (perhaps extended to even more bits than normally by
    continuing with extended values of operands after running of normal bits)
    and in addition to that trying to compute if certain sets of bits are
either
    all zero or all sign extensions of the least significant bit.

    That code is in a lot of cases guarded just by a single condition (which
    can be idx > startlimb, idx >= startlimb or idx == startlimb) or by
    2 conditions - if (idx >= startlimb) { if (idx == startlimb) ... else ... }
    Now, if_then_if_then_else when the second argument is NULL works just as
    if_then and sets m_gsi to be within the initially empty then block and that
is
    where we emit code for constant tidx startlimb + (cmp_code == GT_EXPR).
    But in the 2 conditions case, m_gsi is set to the initially empty else
    block, so using EQ_EXPR for the condition was incorrect (and strangely
    nothing in the testsuite caught that), because the code for extracting the
    lowest set of bits (i.e. when tidx is startlimb) is then done when idx
    is not startlimb rather than when it is.
    The following patch fixes that.

    Note, when developing the lowering, I was using gcov to make sure all code
    is covered by the testsuite with minimum exceptions, so no idea how this
    slipped out.

    2023-12-01  Jakub Jelinek  <ja...@redhat.com>

            PR middle-end/112750
            * gimple-lower-bitint.cc
(bitint_large_huge::lower_addsub_overflow):
            Use NE_EXPR rather than EQ_EXPR for g2 if !single_comparison and
            adjust probabilities.

            * gcc.dg/bitint-41.c: Use -std=c23 rather than -std=c2x.
            * gcc.dg/torture/bitint-43.c: Likewise.
            * gcc.dg/torture/bitint-44.c: Likewise.
            * gcc.dg/torture/bitint-45.c: New test.

Reply via email to