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

--- Comment #11 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Richard Sandiford <rsand...@gcc.gnu.org>:

https://gcc.gnu.org/g:5cb46d8fff07afee5ca828303544025e4a2e17b7

commit r16-1101-g5cb46d8fff07afee5ca828303544025e4a2e17b7
Author: Richard Sandiford <richard.sandif...@arm.com>
Date:   Wed Jun 4 13:36:51 2025 +0100

    emit-rtl: Tweak validate_subreg ordered_p condition [PR120447]

    In the comment trail for PR119966, I'd said that the validate_subreg
    condition:

      /* The outer size must be ordered wrt the register size, otherwise
         we wouldn't know at compile time how many registers the outer
         mode occupies.  */
      if (!ordered_p (osize, regsize))
        return false;

    "is also potentially relevant" for paradoxical subregs.  But I'd
    forgotten an important caveat.  If the inner size is smaller than
    a register, we know that the inner value will only occupy a single
    register.  Although the paradoxical subreg might extend that single
    register to multiple registers by padding with undefined bits,
    the register size that matters for the extension is:

       REGMODE_NATURAL_SIZE (omode)

    rather than regsize's:

       REGMODE_NATURAL_SIZE (imode)

    The ordered check is still relevant if the inner value spans
    multiple registers.

    Enabling the check above for paradoxical subregs led to an ICE in the
    testcase, where we tried to generate a VNx4QI paradoxical subreg of a
    QI scalar.  This was previously allowed, and AFAIK worked correctly.

    The patch doesn't have the effect of relaxing the condition for
    non-paradoxical subregs, since:

      known_le (osize, isize) && known_le (isize, regsize)
        => known_le (osize, regsize)
        => ordered_p (osize, regsize)

    So even before the patch for PR119966, the condition only existed for
    the maybe_gt (isize, regsize) case.

    The term "block" used in the comment is taken from the rtl.texi
    documentation of subregs.

    gcc/
            PR rtl-optimization/120447
            * emit-rtl.cc (validate_subreg): Restrict ordered_p test
            between osize and regsize to cases where the inner value
            occupies multiple blocks.

    gcc/testsuite/
            PR rtl-optimization/120447
            * gcc.dg/pr120447.c: New test.

Reply via email to