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

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

https://gcc.gnu.org/g:486c6296ed318d0df27a053d2288b6f4fa47517d

commit r17-4989-g486c6296ed318d0df27a053d2288b6f4fa47517d
Author: Kyrylo Tkachov <[email protected]>
Date:   Wed Oct 7 17:29:35 2026 +0200

    simplify-rtx: Fix ICE in the VEC_CONCAT halves fold [PR127483]

    simplify_binary_operation_1 simplifies the concatenation of the two
    halves of an object to gen_lowpart of the object.  get_ref_base_and_offset
    can return any rtx as the object, such as an UNSPEC, but gen_lowpart
    asserts for an UNSPEC in another mode.

    For example, on AArch64 fwprop1 tries to propagate the result of an LD2
    into the operands of an ADDP for:

      uint8x8x2_t v = vld2_u8 (p);
      return vpadd_u8 (v.val[0], v.val[1]);

    The ADDP operands then contain:

      (vec_concat:V16QI
        (subreg:V8QI (unspec:V2x8QI [(mem:V2x8QI (reg:DI p))] UNSPEC_LD2_DREG)
0)
        (subreg:V8QI (unspec:V2x8QI [(mem:V2x8QI (reg:DI p))] UNSPEC_LD2_DREG)
8))

    and gen_lowpart (V16QImode, (unspec:V2x8QI ...)) fails the assert.  The
    x86_64 testcase in the PR reaches the fold through debug insns.

    Use rtl_hooks.gen_lowpart_no_emit, like the other simplifications in this
    file, and do not fold if it fails.  Unlike gen_lowpart, the hook also
    never emits instructions.

    Bootstrapped and tested on x86_64-pc-linux-gnu.

    gcc/ChangeLog:

            PR rtl-optimization/127483
            * simplify-rtx.cc (simplify_context::simplify_binary_operation_1)
            <case VEC_CONCAT>: Use rtl_hooks.gen_lowpart_no_emit rather than
            gen_lowpart, and do not fold if it fails.

    gcc/testsuite/ChangeLog:

            PR rtl-optimization/127483
            * gcc.dg/pr127483.c: New test.
            * gcc.target/aarch64/pr127483.c: Likewise.
            * gcc.target/aarch64/pr127483-be.c: Likewise.

    Signed-off-by: Kyrylo Tkachov <[email protected]>

Reply via email to