https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118273
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Tamar Christina <tnfch...@gcc.gnu.org>: https://gcc.gnu.org/g:1dd79f44dfb64b441f3d6c64e7f909d73441bd05 commit r15-7095-g1dd79f44dfb64b441f3d6c64e7f909d73441bd05 Author: Tamar Christina <tamar.christ...@arm.com> Date: Tue Jan 21 10:29:08 2025 +0000 middle-end: use ncopies both when registering and reading masks [PR118273] When registering masks for SIMD clone we end up using nmasks instead of nvectors where nmasks seems to compute the number of input masks required for the call given the current simdlen. This is however wrong as vect_record_loop_mask wants to know how many masks you want to create from the given vectype. i.e. which level of rgroups to create. This ends up mismatching with vect_get_loop_mask which uses nvectors and if the return type is narrower than the input types there will be a mismatch which causes us to try to read from the given rgroup. It only happens to work if the function had an additional argument that's wider or if all elements and return types are the same size. This fixes it by using nvectors during registration as well, which has already taken into account SLP and VF. gcc/ChangeLog: PR middle-end/118273 * tree-vect-stmts.cc (vectorizable_simd_clone_call): Use nvectors when doing mask registrations. gcc/testsuite/ChangeLog: PR middle-end/118273 * gcc.target/aarch64/vect-simd-clone-4.c: New test.