]> git.ipfire.org Git - thirdparty/gcc.git/commit
DSE: Support triming of some more memset [PR87901]
authorAndrew Pinski <quic_apinski@quicinc.com>
Tue, 8 Apr 2025 00:06:17 +0000 (17:06 -0700)
committerAndrew Pinski <quic_apinski@quicinc.com>
Fri, 18 Apr 2025 16:13:48 +0000 (09:13 -0700)
commit800b3977031dd4f14d09ced975276e09457dfff7
tree7b1d28eb84360625692bf05624ecee9c597e7ff6
parent16082bdc6beef1ca1485ed5ccdc0c52aabbe0f4c
DSE: Support triming of some more memset [PR87901]

DSE has support for trimming memset (and memset like) statements.
In this case we have `MEM <unsigned char[17]> [(char * {ref-all})&z] = {};` in
the IR and when we go to trim it, we call build_fold_addr_expr which leaves around
a cast from one pointer type to another. This is due to build_fold_addr_expr
being generic but in gimple you don't need these casts.

PR tree-optimization/87901

gcc/ChangeLog:

* tree-ssa-dse.cc (maybe_trim_constructor_store): Strip over useless type
conversions after taking the address of the MEM_REF.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/ssa-dse-52.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-52.c [new file with mode: 0644]
gcc/tree-ssa-dse.cc