https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128773
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Tamar Christina <[email protected]>: https://gcc.gnu.org/g:31569570cc40efa7d7c6a67ad68a76a00ff4e0fd commit r17-6846-g31569570cc40efa7d7c6a67ad68a76a00ff4e0fd Author: Tamar Christina <[email protected]> Date: Mon Nov 30 14:28:42 2026 +0000 AArch64: clear upper bits of 128-bit vector lowering PR128773 The example sum_16_bytes (unsigned char *p, svuint8_t ones) { svst1_u8 (svptrue_pat_b8 (SV_VL16), p, ones); svuint8_t v = svld1_u8 (svptrue_pat_b8 (SV_VL16), p); return svaddv_u8 (svptrue_b8 (), v); } shows that the SVE to Adv. SIMD Neon lowering can also cause a miscompilation for non-scalar modes. This is because even though the full vector is written, the entire load can be removed. The above generates sum_16_bytes: ptrue p3.b, all str q0, [x0] uaddv d31, p3, z0.b fmov x0, d31 ret which is bogus because uaddv now runs on uninitialized bits. To fix this extend the zero-ing optimization to 128-bit vectors as well. The zero'ing idiom used here is a vector mov. The above now generates sum_16_bytes: ptrue p3.b, all str q0, [x0] mov v0.16b, v0.16b uaddv d31, p3, z0.b fmov x0, d31 ret However because these can become Q sized loads and can be used inside an LDP, in order for us not to lose the LDP we have to re-write the INSR away from the load. We can't do this before reload, but can after reload and leave the late LDP pass to recover the pairs. gcc/ChangeLog: PR target/128773 * config/aarch64/aarch64-sve.md (*aarch64_vec_shl_insert_v16qi_into_zero): New. * config/aarch64/aarch64.cc (aarch64_expand_maskloadstore): Check for SIMD available for 128 bit vector moves. (aarch64_sve_load_elt0): Move. (aarch64_emit_load_store_through_mode): Use it. gcc/testsuite/ChangeLog: PR target/128773 * gcc.target/aarch64/sve/maskload_zero_upper_128_run.c: New test.
