https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63185

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
comment#5 runs into the fact that we cannot reliably compute kills for
loop-variant stores and thus we give up completely:

      if (gimple_code (temp) == GIMPLE_PHI)
        {
          /* If we visit this PHI by following a backedge then we have to
             make sure ref->ref only refers to SSA names that are invariant
             with respect to the loop represented by this PHI node.  */
          if (dominated_by_p (CDI_DOMINATORS, gimple_bb (stmt),
                              gimple_bb (temp))
              && !for_each_index (ref->ref ? &ref->ref : &ref->base,
                                  check_name, gimple_bb (temp)))
            return DSE_STORE_LIVE;

but what we could do is somehow massage the ref to not get false
positive stmt_kills_ref_p or false negative ref_maybe_used_by_stmt_p
results.  That could for example involve stripping all components
with variable names in them (and then also disabling byte-tracking).
For varying bases we still need to give up completely.

A backward data-flow algorithm might have an easier time dealing with this
case.


As for the value-numbering issue we currently do not use number of iteration
analysis / range-info to constrain the ao_ref max_size/offset.  That's probably
a useful thing to add and might already help.  In this case it doesn't
because the range is one too large (head controlled loop).  And VRP doesn't
run after CH when FRE/PRE still runs afterwards.  And value-numbering visiting
memset doesn't handle pointer destinations (that's easy to fix).

Reply via email to