https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128773
--- Comment #3 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:c2b002080fc88ad2cbe5334a06fc5383344b9059 commit r17-6845-gc2b002080fc88ad2cbe5334a06fc5383344b9059 Author: Minh Quan Ho <[email protected]> Date: Tue Nov 24 15:12:03 2026 +0100 aarch64: Zero the upper bits of 64-bit partial-ptrue loads [PR128773] aarch64_expand_maskloadstore turns an SVE masked load or store whose predicate is a partial PTRUE covering at most 128 bits into an Advanced SIMD access. PR125148 changed aarch64_emit_load_store_through_mode so that scalar (1, 2 and 4 byte) loads are inserted into an explicitly zeroed SVE register. Accesses of 64 bits still use V8QImode, which goes through the vector path of that function and reaches the SVE register through a paradoxical subreg. The bits above the loaded 64 are then undefined in RTL even though the masked load requires them to be zero, and DSE can forward the upper bytes of an earlier wider store into them: vf init = svdupq_f64 (12.0, 24.0); svst1 (svptrue_b64 (), arr, init); vf r = svld1 (svdupq_b64 (1, 0), arr); /* lane 1 must be 0 */ gives lane 1 == 24 at -O1 and above, for any vector length (-msve-vector-bits=128/256/512 and VLA). The same holds for every 64-bit partial PTRUE: .d VL1, .s VL2, .h VL4 and .b VL8. Fix it by removing the V8QImode case, so that 64-bit accesses use DImode like the narrower ones. Loads are then inserted into an explicitly zeroed register; the existing *aarch64_vec_shl_insert_from_load_<mode> pattern still emits a single LDR Dn when the value comes straight from memory. Stores still emit a single STR Dn, as checked by ldst_ptrue_pat_128_to_neon.c. gcc/ChangeLog: PR target/128773 * config/aarch64/aarch64.cc (aarch64_expand_maskloadstore): Remove the V8QImode case, so that 64-bit accesses use DImode. gcc/testsuite/ChangeLog: PR target/128773 * gcc.target/aarch64/sve/maskload_zero_upper_run.c: New test. Signed-off-by: Minh-Quan Ho <[email protected]> AI-assisted by: Claude Opus 5.5
