https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122635
--- Comment #21 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:cee0a9dd2700b9adff64b2d7e1f222671b1b2058 commit r16-5984-gcee0a9dd2700b9adff64b2d7e1f222671b1b2058 Author: Robin Dapp <[email protected]> Date: Tue Nov 25 10:34:55 2025 +0100 fold: Elide MASK_LEN_LOAD/STORE with zero length [PR122635]. This patch adds zero-length handling to gimple_fold_partial_store and gimple_fold_partial_load and unifies them into gimple_fold_partial_load_store. It introduces a new function partial_load_store_mask_state that returns MASK_ALL_INACTIVE, MASK_ALL_ACTIVE, or MASK_UNKNOWN. This result is used to either replace a load with its else value and elide a store (when all inactive), turn the load/store into a regular mem ref (all_active), or do nothing. PR tree-optimization/122635 gcc/ChangeLog: * gimple-fold.cc (enum mask_load_store_state): New enum. (gimple_fold_partial_load_store_mem_ref): Only fold "all active" loads/stores. (partial_load_store_mask_state): New function to compute mask state. (gimple_fold_partial_load): Remove. (gimple_fold_partial_load_store): New function. (gimple_fold_partial_store): Remove. (gimple_fold_call): Use new function. gcc/testsuite/ChangeLog: * gcc.target/aarch64/sve/pfalse-store.c: Expect more elided stores. * gcc.target/riscv/rvv/autovec/pr122635-1.c: New test. * gcc.target/riscv/rvv/autovec/pr122635-2.c: New test. * gcc.target/powerpc/p9-vec-length-epil-8.c: Expect two lxvl less.
