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

--- Comment #1 from Jeffrey A. Law <law at redhat dot com> ---
So the missed dead stores are due to DSE's inability to walk through the loop
in ReleaseAll.  As a result stores occurring prior to that loop can't be
discovered as dead.

For reference, here's an example that's already been partially DSE'd:

;;   basic block 2, loop depth 0
;;    pred:       ENTRY
  # .MEM_3 = VDEF <.MEM_1(D)>
  f_2(D)->D.2321.b0 = 192;
  # .MEM_4 = VDEF <.MEM_3>
  f_2(D)->m1 = 42;
  # .MEM_18 = VDEF <.MEM_4>
  f_2(D)->m1 = 1;
  # .MEM_19 = VDEF <.MEM_18>
  f_2(D)->m2 = 2;
  # VUSE <.MEM_19>
  n_8 = f_2(D)->nodes;
  if (n_8 == 0B)
    goto <bb 4>; [7.50%]
  else
    goto <bb 3>; [92.50%]
;;    succ:       4
;;                3

;;   basic block 3, loop depth 1
;;    pred:       3
;;                2
  # n_12 = PHI <t_10(3), n_8(2)>
  # .MEM_21 = PHI <.MEM_20(3), .MEM_19(2)>
  # VUSE <.MEM_21>
  t_10 = n_12->next;
  # .MEM_20 = VDEF <.MEM_21>
  operator delete (n_12, 16);
  if (t_10 == 0B)
    goto <bb 4>; [7.50%]
  else
    goto <bb 3>; [92.50%]
;;    succ:       4
;;                3

;;   basic block 4, loop depth 0
;;    pred:       3
;;                2
  # .MEM_14 = PHI <.MEM_20(3), .MEM_19(2)>
  # .MEM_7 = VDEF <.MEM_14>
  MEM[(struct  &)f_2(D)] ={v} {CLOBBER};
  # .MEM_5 = VDEF <.MEM_7>
  operator delete (f_2(D), 32);
  # VUSE <.MEM_5>
  return;
;;    succ:       EXIT

}

We'd like to discover the stores in bb2 as dead.  Let's look at f2->m2 = 2
first.  MEM_19 is used by the PHI in BB3.  So we'd have to walk through the
loop following the memory objects, eventually hoping to get to BB4 where we
discover the object dies.

DSE gets very careful walking through loops and thus is unable to handle this
particular case.

Reply via email to