If a phi node has been resized using resize_phi_node, it may later be attempted
to be removed by remove_dead_inserted_code using remove_phi_node, as the old
phi node will be present in inserted_exprs, yet the phi node will not be in the
chain of phi nodes for its original basic block.

I believe the fix is to make remove_phi_node bail out if the phi node is not
present in the list of phi nodes for its basic block:

void
remove_phi_node (tree phi, tree prev)
{
  tree *loc;

  if (prev)
    {
      loc = &PHI_CHAIN (prev);
    }
  else
    {
      for (loc = &(bb_for_stmt (phi)->phi_nodes);
           loc && *loc != phi;
           loc = &PHI_CHAIN (*loc))
        ;
    }
  if (!loc) return;

  /* Remove PHI from the chain.  */
  *loc = PHI_CHAIN (phi);

  /* If we are deleting the PHI node, then we should release the
     SSA_NAME node so that it can be reused.  */
  release_phi_node (phi);
  release_ssa_name (PHI_RESULT (phi));
}


-- 
           Summary: remove_phi_node attempts removal of a phi node resized
                    by resize_phi_node
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: hosking at cs dot purdue dot edu
 GCC build triplet: i386-apple-darwin8.7.1
  GCC host triplet: i386-apple-darwin8.7.1
GCC target triplet: i386-apple-darwin8.7.1


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28798

Reply via email to