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

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Well, the issue is simply that we don't remove the volatile load and the
call to 'new' is thought to possibly be a definition of 'd' via
stmt_may_clobber_ref_p_1 which is because there's a volatile_p check
before the may_be_aliased check:

  /* A call that is not without side-effects might involve volatile
     accesses and thus conflicts with all other volatile accesses.  */
  if (ref->volatile_p)
    return true;

  /* If the reference is based on a decl that is not aliased the call
     cannot possibly clobber it.  */
  if (DECL_P (base)
      && !may_be_aliased (base)
      /* But local non-readonly statics can be modified through recursion
         or the call may implement a threading barrier which we must
         treat as may-def.  */
      && (TREE_READONLY (base)
          || !is_global_var (base)))
    return false;

so it indeed seems we're overly cautionous about this here and we could
relax the volatile checks.

Reply via email to