]> git.ipfire.org Git - thirdparty/gcc.git/commit
gimple-fold: Move optimizing memcpy to memset to fold_stmt from fab
authorAndrew Pinski <quic_apinski@quicinc.com>
Fri, 6 Sep 2024 19:29:26 +0000 (12:29 -0700)
committerAndrew Pinski <quic_apinski@quicinc.com>
Mon, 9 Sep 2024 08:12:52 +0000 (01:12 -0700)
commit2067df800df930dd13aa20a826373bb27cfdd420
tree558ce9fc7c427bcab9ed9ba131f035f78ae44fc0
parent924855daa204b4821057313cad44898445824e11
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_apinski@quicinc.com>
gcc/gimple-fold.cc
gcc/testsuite/g++.dg/torture/except-2.C [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr78408-1.c
gcc/tree-ssa-ccp.cc