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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
           Assignee|unassigned at gcc dot gnu.org      |pinskia at gcc dot 
gnu.org
           Keywords|needs-bisection             |
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2024-10-01

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Deleting v_17 = PHI <{ 0.0, 0.0, 0.0, 0.0 }(4), v_19(6)>



static void
remove_unused_var (tree var)
{
  gimple *stmt = SSA_NAME_DEF_STMT (var);
  if (dump_file && (dump_flags & TDF_DETAILS))
    {
      fprintf (dump_file, "Deleting ");
      print_gimple_stmt (dump_file, stmt, 0, TDF_SLIM);
    }
  gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
  gsi_remove (&gsi, true);
  release_defs (stmt);
}


That is wrong for phis.

It should have been something like:
      if (gimple_code (t) == GIMPLE_PHI)
        {
          remove_phi_node (&gsi, true);
          phiremoved++;
        }
      else
        {
          unlink_stmt_vdef (t);
          gsi_remove (&gsi, true);
          release_defs (t);
          stmtremoved++;
        }

remove_unused_var was added in GCC 6 though; r6-4109-g6a75d560c85508 .

Though backprop didn't start doing something for this testcase until GCC 10.

This should be easy to fix.

I am going to do 2 patches, one to fix remove_unused_var to use the correct way
of removing the phis. And then secondary change the code to use
simple_dce_from_worklist (if I get a chance).

Reply via email to