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

--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <[email protected]>:

https://gcc.gnu.org/g:2149eda29e2628d31faf44da060139a856c47b3f

commit r16-7277-g2149eda29e2628d31faf44da060139a856c47b3f
Author: Jakub Jelinek <[email protected]>
Date:   Wed Feb 4 11:25:01 2026 +0100

    bitint: Don't try to extend PHI in the min_prec == prec case [PR122689]

    The following testcase is miscompiled on aarch64-linux, the problem is that
    the PHI argument is lowered to
      VIEW_CONVERT_EXPR<unsigned long[196]>(y) = VIEW_CONVERT_EXPR<unsigned
long[196]>(*.LC0);
      MEM <unsigned long[1]> [(unsigned _BitInt(12419) *)&y + 1568B] = {};
    on the edge, where for aarch64 unsigned _BitInt(12419) the size of the type
    is already 1568 bytes (aka 196 DImode limbs, 98 TImode ABI limbs), so the
    fir stmt copies everything and the second stmt clobbers random unrelated
memory
    after it.

    Usually when min_prec == prec (otherwise we guarantee that min_prec is
either 0,
    or a single limb (which doesn't have padding bits) or something without any
    padding bits (multiple of abi_limb_prec)) we take the
                      if (c)
                        {
                          if (VAR_P (v1) && min_prec == prec)
                            {
                              tree v2 = build1 (VIEW_CONVERT_EXPR,
                                                TREE_TYPE (v1), c);
                              g = gimple_build_assign (v1, v2);
                              gsi_insert_on_edge (e, g);
                              edge_insertions = true;
                              break;
                            }
    path and need nothing else, but in this case v1 is a PARM_DECL, so we need
to
    take the code path with VCE on the lhs side as well.  But after the
assignment
    we fall through into the handling of the extension, but for min_prec ==
prec
    that isn't needed and is actually harmful, we've already copied everything
    and the code later on assumes there are no padding bits and uses just
    TYPE_SIZE_UNIT.

    So, this patch just avoids the rest after we've copied all the bits for
    min_prec == prec.

    2026-02-04  Jakub Jelinek  <[email protected]>

            PR middle-end/122689
            * gimple-lower-bitint.cc (gimple_lower_bitint): For the PHI
handling
            if min_prec == prec, break after emitting assignment from c.

            * gcc.dg/bitint-127.c: New test.

Reply via email to