https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118947
--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Andrew Pinski <pins...@gcc.gnu.org>: https://gcc.gnu.org/g:94f275432f7ea4781ec7c05fa9d1d81ef6cb3fc1 commit r16-22-g94f275432f7ea4781ec7c05fa9d1d81ef6cb3fc1 Author: Andrew Pinski <quic_apin...@quicinc.com> Date: Thu Feb 20 16:09:05 2025 -0800 gimple-fold: Improve optimize_memcpy_to_memset to handle STRING_CST [PR78408] While looking into PR 118947, I noticed that optimize_memcpy_to_memset didn't handle STRING_CST which are also used for a memset of 0 but for char arrays. This fixes that and improves optimize_memcpy_to_memset to handle that case. This fixes part of PR 118947 but not the whole thing; we still need to skip over vdefs in some cases. Boostrapped and tested on x86_64-linux-gnu. PR tree-optimization/78408 PR tree-optimization/118947 gcc/ChangeLog: * gimple-fold.cc (optimize_memcpy_to_memset): Handle STRING_CST case too. gcc/testsuite/ChangeLog: * gcc.dg/pr78408-3.c: New test. Signed-off-by: Andrew Pinski <quic_apin...@quicinc.com>