From: Jeff Law Date: Fri, 6 Jul 2018 03:43:42 +0000 (-0600) Subject: re PR tree-optimization/86010 (redundant memset with smaller size not eliminated) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=99e87c0eef2f6020a3ded2c785389939c07ac04e;p=gcc.git re PR tree-optimization/86010 (redundant memset with smaller size not eliminated) PR tree-optimization/86010 * tree-ssa-dse.c (compute_trims): More aggressively trim at both the head and tail of mem* and str* calls. From-SVN: r262464 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 22991846d52..61fc28f076e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-07-05 Jeff Law + + PR tree-optimization/86010 + * tree-ssa-dse.c (compute_trims): More aggressively trim at + both the head and tail of mem* and str* calls. + 2018-07-05 Jim Wilson * config.gcc (riscv*-*-*): When setting xlen, handle riscv-*. diff --git a/gcc/tree-ssa-dse.c b/gcc/tree-ssa-dse.c index 1af50a02674..ebc4a1e0fc1 100644 --- a/gcc/tree-ssa-dse.c +++ b/gcc/tree-ssa-dse.c @@ -240,11 +240,14 @@ compute_trims (ao_ref *ref, sbitmap live, int *trim_head, int *trim_tail, /* Now identify how much, if any of the tail we can chop off. */ HOST_WIDE_INT const_size; + int last_live = bitmap_last_set_bit (live); if (ref->size.is_constant (&const_size)) { int last_orig = (const_size / BITS_PER_UNIT) - 1; - int last_live = bitmap_last_set_bit (live); - *trim_tail = (last_orig - last_live) & ~0x1; + /* We can leave inconvenient amounts on the tail as + residual handling in mem* and str* functions is usually + reasonably efficient. */ + *trim_tail = last_orig - last_live; } else *trim_tail = 0; @@ -252,7 +255,12 @@ compute_trims (ao_ref *ref, sbitmap live, int *trim_head, int *trim_tail, /* Identify how much, if any of the head we can chop off. */ int first_orig = 0; int first_live = bitmap_first_set_bit (live); - *trim_head = (first_live - first_orig) & ~0x1; + *trim_head = first_live - first_orig; + + /* If more than a word remains, then make sure to keep the + starting point at least word aligned. */ + if (last_live - first_live > UNITS_PER_WORD) + *trim_head &= (UNITS_PER_WORD - 1); if ((*trim_head || *trim_tail) && dump_file && (dump_flags & TDF_DETAILS))