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

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

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

commit r16-6975-gca5a68ac28013530782f8a1ba021c18de561fa7c
Author: Robin Dapp <[email protected]>
Date:   Fri Jan 2 16:57:21 2026 +0100

    RISC-V: Fix intrinsic FoF load at -O0 [PR122869].

    In the PR we try to compile a loop at -O0 with fault-only-first loads.
    We use the VL adjusted by the FoF loads to count the number of
    processed elements.  Currently, this is implemented as "folding" the FoF
    load into a FoF load and a riscv_read_vl directly after.
    We cannot guarantee the value of VL between two calls, though.  It is
    possible that we need a vector store in between which would clobber VL.

    This patch makes the VL -> pseudo semantics of the FoF insn explicit and
    adjusts the intrinsics expander accordingly.

    There is a problem with this approach, though:  Technically, the VL
    adjustment of the FoF loads is modelled as a store and the VL variable
    is made TREE_ADDRESSABLE.  At the gimple level we managed to elide the
    store very early but at RTL level we don't.  Also, we don't manage to
    re-use the same register for VL at -O2 and -O3 while it still works for
    -O1.

    What might help with the second issue above is to add value tracking
    to the vsetvl pass.  I suppose the first issue would require a larger
    intervention.

            PR target/122869

    gcc/ChangeLog:

            * config/riscv/riscv-vector-builtins-bases.cc (fold_fault_load):
            Remove
            * config/riscv/riscv-vector-builtins.cc
(function_expander::use_contiguous_load_insn):
            Use new helper.
            (function_expander::prepare_contiguous_load_insn): New helper.
            (function_expander::use_fof_load_insn): New function to emit FoF
            loads.
            * config/riscv/riscv-vector-builtins.h: Declare new functions.

    gcc/testsuite/ChangeLog:

            * gcc.target/riscv/rvv/base/pr122656-1.c: Remove dg-error.
            * gcc.target/riscv/rvv/vsetvl/ffload-3.c: XFAIL for -O2 and -O3.
            * gcc.target/riscv/rvv/base/pr122869.c: New test.
  • [Bug target/122869] risc-v loop... cvs-commit at gcc dot gnu.org via Gcc-bugs

Reply via email to