https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107957
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Georg-Johann Lay <g...@gcc.gnu.org>: https://gcc.gnu.org/g:bf6f77edd625cfe2f2f164e90437df318b96527f commit r15-5938-gbf6f77edd625cfe2f2f164e90437df318b96527f Author: Georg-Johann Lay <a...@gjlay.de> Date: Thu Dec 5 11:24:30 2024 +0100 AVR: target/107957 - Propagate zero_reg to store sources. When -msplit-ldst is on, it may be possible to propagate __zero_reg__ to the sources of the new stores. For example, without this patch, unsigned long lx; void store_lsr17 (void) { lx >>= 17; } compiles to: store_lsr17: lds r26,lx+2 ; movqi_insn lds r27,lx+3 ; movqi_insn movw r24,r26 ; *movhi lsr r25 ; *lshrhi3_const ror r24 ldi r26,0 ; movqi_insn ldi r27,0 ; movqi_insn sts lx,r24 ; movqi_insn sts lx+1,r25 ; movqi_insn sts lx+2,r26 ; movqi_insn sts lx+3,r27 ; movqi_insn ret but with this patch it becomes: store_lsr17: lds r26,lx+2 ; movqi_insn lds r27,lx+3 ; movqi_insn movw r24,r26 ; *movhi lsr r25 ; *lshrhi3_const ror r24 sts lx,r24 ; movqi_insn sts lx+1,r25 ; movqi_insn sts lx+2,__zero_reg__ ; movqi_insn sts lx+3,__zero_reg__ ; movqi_insn ret gcc/ PR target/107957 * config/avr/avr-passes-fuse-move.h (bbinfo_t) <try_mem0_p>: Add static property. * config/avr/avr-passes.cc (bbinfo_t::try_mem0_p): Define it. (optimize_data_t::try_mem0): New method. (bbinfo_t::optimize_one_block) [bbinfo_t::try_mem0_p]: Run try_mem0. (bbinfo_t::optimize_one_function): Set bbinfo_t::try_mem0_p. * config/avr/avr.md (pushhi1_insn): Also allow zero as source. (define_split) [avropt_split_ldst]: Only run avr_split_ldst() when avr-fuse-move has been run at least once. * doc/invoke.texi (AVR Options) <-msplit-ldst>: Document it.