diff options
author | Jeff Law <law@redhat.com> | 2019-07-19 11:04:51 -0600 |
---|---|---|
committer | Jeff Law <law@gcc.gnu.org> | 2019-07-19 11:04:51 -0600 |
commit | 192ece9e15d25fd9b6534b2a8bd271684bf76d38 (patch) | |
tree | cafced4d63e287c50081c43251c95d717ea12d4a /gcc/tree-ssa-dse.c | |
parent | 6b68f00d4c2b375dad66bd6e72c01c309b4085c5 (diff) | |
download | gcc-192ece9e15d25fd9b6534b2a8bd271684bf76d38.zip gcc-192ece9e15d25fd9b6534b2a8bd271684bf76d38.tar.gz gcc-192ece9e15d25fd9b6534b2a8bd271684bf76d38.tar.bz2 |
tree-ssa-dse.c (initialize_ao_ref_for_dse): Handle strncpy.
* tree-ssa-dse.c (initialize_ao_ref_for_dse): Handle
strncpy. Drop some trivial dead code.
(maybe_trim_memstar_call): Handle strncpy.
* gcc.dg/tree-ssa/ssa-dse-37.c: New test.
* gcc.dg/tree-ssa/ssa-dse-38.c: New test.
From-SVN: r273606
Diffstat (limited to 'gcc/tree-ssa-dse.c')
-rw-r--r-- | gcc/tree-ssa-dse.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/gcc/tree-ssa-dse.c b/gcc/tree-ssa-dse.c index 9bdcf9a..5b7c4fc 100644 --- a/gcc/tree-ssa-dse.c +++ b/gcc/tree-ssa-dse.c @@ -113,10 +113,10 @@ initialize_ao_ref_for_dse (gimple *stmt, ao_ref *write) case BUILT_IN_MEMCPY_CHK: case BUILT_IN_MEMMOVE_CHK: case BUILT_IN_MEMSET_CHK: + case BUILT_IN_STRNCPY: + case BUILT_IN_STRNCPY_CHK: { - tree size = NULL_TREE; - if (gimple_call_num_args (stmt) == 3) - size = gimple_call_arg (stmt, 2); + tree size = gimple_call_arg (stmt, 2); tree ptr = gimple_call_arg (stmt, 0); ao_ref_init_from_ptr_and_size (write, ptr, size); return true; @@ -469,8 +469,10 @@ maybe_trim_memstar_call (ao_ref *ref, sbitmap live, gimple *stmt) { case BUILT_IN_MEMCPY: case BUILT_IN_MEMMOVE: + case BUILT_IN_STRNCPY: case BUILT_IN_MEMCPY_CHK: case BUILT_IN_MEMMOVE_CHK: + case BUILT_IN_STRNCPY_CHK: { int head_trim, tail_trim; compute_trims (ref, live, &head_trim, &tail_trim, stmt); @@ -966,9 +968,11 @@ dse_dom_walker::dse_optimize_stmt (gimple_stmt_iterator *gsi) { case BUILT_IN_MEMCPY: case BUILT_IN_MEMMOVE: + case BUILT_IN_STRNCPY: case BUILT_IN_MEMSET: case BUILT_IN_MEMCPY_CHK: case BUILT_IN_MEMMOVE_CHK: + case BUILT_IN_STRNCPY_CHK: case BUILT_IN_MEMSET_CHK: { /* Occasionally calls with an explicit length of zero |