https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87901
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #4) > Note for s/17/16/ we still fail; I will handle that afterwards. That was easy to handle also: ``` diff --git a/gcc/tree-ssa-dse.cc b/gcc/tree-ssa-dse.cc index 82ebc99686c..b97e833a0ea 100644 --- a/gcc/tree-ssa-dse.cc +++ b/gcc/tree-ssa-dse.cc @@ -566,16 +566,17 @@ maybe_trim_complex_store (ao_ref *ref, sbitmap live, gimple *stmt) The most common case for getting here is a CONSTRUCTOR with no elements being used to zero initialize an object. We do not try to handle other cases as those would force us to fully cover the object with the - CONSTRUCTOR node except for the components that are dead. */ + CONSTRUCTOR node except for the components that are dead. + Also handles integer stores of 0 which can happen with memset/memcpy optimizations. */ static void -maybe_trim_constructor_store (ao_ref *ref, sbitmap live, gimple *stmt) +maybe_trim_constructor_store (ao_ref *ref, sbitmap live, gimple *stmt, bool was_integer_cst = false) { tree ctor = gimple_assign_rhs1 (stmt); /* This is the only case we currently handle. It actually seems to catch most cases of actual interest. */ - gcc_assert (CONSTRUCTOR_NELTS (ctor) == 0); + gcc_assert (was_integer_cst ? integer_zerop (ctor) : CONSTRUCTOR_NELTS (ctor) == 0); int head_trim = 0; int tail_trim = 0; @@ -809,6 +810,10 @@ maybe_trim_partially_dead_store (ao_ref *ref, sbitmap live, gimple *stmt) case COMPLEX_CST: maybe_trim_complex_store (ref, live, stmt); break; + case INTEGER_CST: + if (integer_zerop (gimple_assign_rhs1 (stmt))) + maybe_trim_constructor_store (ref, live, stmt, true); + break; default: break; } ```