diff options
author | Roger Sayle <roger@nextmovesoftware.com> | 2022-05-13 22:20:16 +0100 |
---|---|---|
committer | Roger Sayle <roger@nextmovesoftware.com> | 2022-05-13 22:20:16 +0100 |
commit | 1fe04c497d5a16baee6af48a0b08ca99b75724e4 (patch) | |
tree | e913d36dacd0894c24eafb38386a16b20036319b /gcc/diagnostic-format-json.cc | |
parent | 16f7fcadac19dabd04a5abbe6601df52d22e9685 (diff) | |
download | gcc-1fe04c497d5a16baee6af48a0b08ca99b75724e4.zip gcc-1fe04c497d5a16baee6af48a0b08ca99b75724e4.tar.gz gcc-1fe04c497d5a16baee6af48a0b08ca99b75724e4.tar.bz2 |
PR tree-optimization/83907: Improved memset handling in strlen pass.
This patch implements the missed optimization enhancement PR 83907,
by handling memset with a constant byte value in tree-ssa's strlen
optimization pass. Effectively, this treats memset(dst,'x',3) as
it would memcpy(dst,"xxx",3).
This patch also includes a tweak to handle_store to address another
missed optimization observed in the related test case pr83907-2.c.
The consecutive byte stores to memory get coalesced into a vector
write of a vector const, but unfortunately tree-ssa-strlen's
handle_store didn't previously handle the (unusual) case where the
stored "string" starts with a zero byte but also contains non-zero
bytes.
2022-05-13 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
PR tree-optimization/83907
* tree-ssa-strlen.cc (handle_builtin_memset): Record a strinfo
for memset with an constant char value.
(handle_store): Improved handling of stores with a first byte
of zero, but not storing_all_zeros_p.
gcc/testsuite/ChangeLog
PR tree-optimization/83907
* gcc.dg/tree-ssa/pr83907-1.c: New test case.
* gcc.dg/tree-ssa/pr83907-2.c: New test case.
Diffstat (limited to 'gcc/diagnostic-format-json.cc')
0 files changed, 0 insertions, 0 deletions