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

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Robin Dapp <rd...@gcc.gnu.org>:

https://gcc.gnu.org/g:f796f819c35cc08e0a6e7242aee92eb96f62a3b5

commit r16-2452-gf796f819c35cc08e0a6e7242aee92eb96f62a3b5
Author: Robin Dapp <rd...@ventanamicro.com>
Date:   Thu Jul 17 11:09:43 2025 +0200

    RISC-V: Rework broadcast handling [PR121073].

    During the last weeks it became clear that our current broadcast
    handling needs an overhaul in order to improve maintainability.
    PR121073 showed that my intermediate fix wasn't enough and caused
    regressions.

    This patch now goes a first step towards untangling broadcast
    (vmv.v.x), "set first" (vmv.s.x), and zero-strided load (vlse).
    Also can_be_broadcast_p is rewritten and strided_broadcast_p is
    introduced to make the distinction clear directly in the predicates.

    Due to the pervasiveness of the patterns I needed to touch a lot
    of places and tried to clear up some things while at it.  The patch
    therefore also introduces new helpers expand_broadcast for vmv.v.x
    that dispatches to regular as well as strided broadcast and
    expand_set_first that does the same thing for vmv.s.x.

    The non-strided fallbacks are now implemented as splitters of the
    strided variants.  This makes it easier to see where and when things
    happen.

    The test cases I touched appeared wrong to me so this patch sets a new
    baseline for some of the scalar_move tests.

    There is still work to be done but IMHO that can be deferred: It would
    be clearer if the three broadcast-like variants differed not just in
    name but also in RTL pattern so matching is not as confusing.  Right now
    vmv.v.x and vmv.s.x only differ in the mask and are interchangeable by
    just changing it from "all ones" to a "single one".

    As last time, I regtested on rv64 and rv32 with strided_broadcast turned
    on and off.  Note there are regressions cond_fma_fnma-[78].c.  Those are
    due to the patch exposing more fwprop/late-combine opportunities.  For
    fma/fnma we don't yet have proper costing for vv/vx in place but I'll
    expect that to be addressed soon and figured we can live with those for
    the time being.

            PR target/121073

    gcc/ChangeLog:

            * config/riscv/autovec-opt.md: Use new helpers.
            * config/riscv/autovec.md: Ditto.
            * config/riscv/predicates.md (strided_broadcast_mask_operand):
            New predicate.
            (strided_broadcast_operand): Ditto.
            (any_broadcast_operand): Ditto.
            * config/riscv/riscv-protos.h (expand_broadcast): Declare.
            (expand_set_first): Ditto.
            (expand_set_first_tu): Ditto.
            (strided_broadcast_p): Ditto.
            * config/riscv/riscv-string.cc (expand_vec_setmem): Use new
            helpers.
            * config/riscv/riscv-v.cc (expand_broadcast): New functionk.
            (expand_set_first): Ditto.
            (expand_set_first_tu): Ditto.
            (expand_const_vec_duplicate): Use new helpers.
            (expand_const_vector_duplicate_repeating): Ditto.
            (expand_const_vector_duplicate_default): Ditto.
            (sew64_scalar_helper): Ditto.
            (expand_vector_init_merge_repeating_sequence): Ditto.
            (expand_reduction): Ditto.
            (strided_broadcast_p): New function.
            (whole_reg_to_reg_move_p): Use new helpers.
            * config/riscv/riscv-vector-builtins-bases.cc: Use either
            broadcast or strided broadcast.
            * config/riscv/riscv-vector-builtins.cc
(function_expander::use_ternop_insn):
            Ditto.
            (function_expander::use_widen_ternop_insn): Ditto.
            (function_expander::use_scalar_broadcast_insn): Ditto.
            * config/riscv/riscv-vector-builtins.h: Declare scalar
            broadcast.
            * config/riscv/vector.md (*pred_broadcast<mode>): Split into
            regular and strided broadcast.
            (*pred_broadcast<mode>_zvfh): Split.
            (pred_broadcast<mode>_zvfh): Ditto.
            (*pred_broadcast<mode>_zvfhmin): Ditto.
            (@pred_strided_broadcast<mode>): Ditto.
            (*pred_strided_broadcast<mode>): Ditto.
            (*pred_strided_broadcast<mode>_zvfhmin): Ditto.

    gcc/testsuite/ChangeLog:

            * gcc.target/riscv/rvv/autovec/vls-vlmax/repeat-6.c: Adjust test
            expectation.
            * gcc.target/riscv/rvv/base/scalar_move-5.c: Ditto.
            * gcc.target/riscv/rvv/base/scalar_move-6.c: Ditto.
            * gcc.target/riscv/rvv/base/scalar_move-7.c: Ditto.
            * gcc.target/riscv/rvv/base/scalar_move-8.c: Ditto.
            * gcc.target/riscv/rvv/base/scalar_move-9.c: Ditto.
            * gcc.target/riscv/rvv/pr121073.c: New test.
  • [Bug target/121073] [16 Regress... cvs-commit at gcc dot gnu.org via Gcc-bugs

Reply via email to