https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116601
--- 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:2067df800df930dd13aa20a826373bb27cfdd420 commit r15-3544-g2067df800df930dd13aa20a826373bb27cfdd420 Author: Andrew Pinski <quic_apin...@quicinc.com> Date: Fri Sep 6 12:29:26 2024 -0700 gimple-fold: Move optimizing memcpy to memset to fold_stmt from fab I noticed this folding inside fab could be done else where and could even improve inlining decisions and a few other things so let's move it to fold_stmt. It also fixes PR 116601 because places which call fold_stmt already have to deal with the stmt becoming a non-throw statement. For the fix for PR 116601 on the branches should be the original patch rather than a backport of this one. Bootstrapped and tested on x86_64-linux-gnu. PR tree-optimization/116601 gcc/ChangeLog: * gimple-fold.cc (optimize_memcpy_to_memset): Move from tree-ssa-ccp.cc and rename. Also return true if the optimization happened. (gimple_fold_builtin_memory_op): Call optimize_memcpy_to_memset. (fold_stmt_1): Call optimize_memcpy_to_memset for load/store copies. * tree-ssa-ccp.cc (optimize_memcpy): Delete. (pass_fold_builtins::execute): Remove code that calls optimize_memcpy. gcc/testsuite/ChangeLog: * gcc.dg/pr78408-1.c: Adjust dump scan to match where the optimization now happens. * g++.dg/torture/except-2.C: New test. Signed-off-by: Andrew Pinski <quic_apin...@quicinc.com>