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

--- Comment #4 from Andrew Macleod <amacleod at redhat dot com> ---
Created attachment 65247
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=65247&action=edit
potential patch

Another option is the attached patch.

It adds an optional flag to simple_dce_from_worklist to avoid deleting
statements. Instead, it rewrites them into zero assignments.  ie like: 
  a_2 = b_1 + 1
gets rewritten into
  a_2 = 0
this will allow b_1 to also potentially be rewritten, and then the next DCE
pass will remove it as there are no other uses of a_2.

It also rewites PHIS nodes that would be deleted into zero arguments 
  p_3 = PHI <0(2), 0(4)>

This effectively removed the uses of ssa_names in the RHS and allows them to be
removed/rewritten as well, yet leaves all the SSA_NAMEs in the IL so there wont
be any interaction with other routines.

It seemed a lot easier to reuse the existing routine than write a new one, and
works better than any of the other solutions I was looking at.

This bootstraps on x86_64 with no regressions..  what do you think?   Is this a
reasonable solution to pursue?  We only need it during early removal of
builtin_unreachable(), as the final version flags them all, and does the
removal at the end of the pass.

Reply via email to