	* df.h (struct df_rd_bb_info): Add rd_lr_eq_regs field.
	* df-problems.c (df_rd_lr_eq_local_compute, df_rd_lr_eq_confluence_n,
	df_rd_lr_eq_transfer_function, df_rd_init_lr_eq_regs): New functions
	to compute registers live for REG_EQUAL and REG_EQUIV notes.
	(df_rd_free_bb_info): Set up rd_lr_eq_regs.
	(df_rd_alloc): Likewise.
	(df_rd_bb_local_compute, df_rd_init_solution): When pruning the RD
	problem to only live DEFs, and DEFs reaching REG_EQUAL and REG_EQUIV
	notes must also be computed, compute a DF_LR-like set for REG_EQUAL
	and REG_EQUIV uses.
	(df_rd_transfer_function): Keep DEFs reaching REG_EQUAL and REG_EQUIV
	notes alive if necessary.
	(df_rd_top_dump): Dump rd_lr_eq_regs.

Index: df.h
===================================================================
--- df.h	(revision 192391)
+++ df.h	(working copy)
@@ -793,6 +793,10 @@ struct df_rd_bb_info
   bitmap_head sparse_kill;
   bitmap_head gen;   /* The set of defs generated in this block.  */
 
+  /* The set of registers that are considered live for the LR&RD
+     problem because they are used in REG_EQUAL or REG_EQUIV nodes.  */
+  bitmap_head rd_lr_eq_regs;
+
   /* The results of the dataflow problem.  */
   bitmap_head in;    /* At the top of the block.  */
   bitmap_head out;   /* At the bottom of the block.  */
Index: df-problems.c
===================================================================
--- df-problems.c	(revision 192391)
+++ df-problems.c	(working copy)
@@ -200,6 +200,95 @@ struct df_rd_problem_data
   bitmap_obstack rd_bitmaps;
 };
 
+/* Liveness sets for EQ_NOTES.  This is a much simplified form of the
+   normal LR problem.  For a given basic block B:
+    * EQ_USE[B] is the set of registers in REG_EQUAL or REG_EQUIV in B
+    * DEF[B] is the DEF set from the LR problem
+    * IN[B] is the set of EQ_USES exposed upward in the CFG but that
+      are not in the LR_IN set (if they're in LR_IN already we have no
+      reason to track them as special-case EQ_USES)
+    * OUT[B] = union_of_succs(IN[B])
+
+   The RD_LR_EQ_REGS bitmap on the RD basic block info is used first
+   to hold the RD_LR_EQ_USE set, computed in df_rd_lr_eq_local_compute.
+   During df_rd_init_solution this set is used to compute the global set,
+   and after df_rd_init_solution RD_LR_EQ_REGS will be the set of registers
+   that would have been in LR_OUT if the registers would have been real
+   uses (and not just EQ_USES).  */
+
+/* Process a list of EQ_USEs for df_rd_bb_local_compute.  */
+static void
+df_rd_lr_eq_local_compute (struct df_rd_bb_info *bb_info,
+			   df_ref *eq_use_rec)
+{
+  while (*eq_use_rec)
+    {
+      df_ref eq_use = *eq_use_rec;
+      unsigned int regno = DF_REF_REGNO (eq_use);
+      if ((!(df->changeable_flags & DF_NO_HARD_REGS))
+	  || (regno >= FIRST_PSEUDO_REGISTER))
+	bitmap_set_bit (&bb_info->rd_lr_eq_regs, regno);
+      eq_use_rec++;
+    }
+}
+
+/* The IN and EQ_USE sets.  EQ_USE will be filled from RD_LR_RQ_REGS.  */
+bitmap_head *rd_lr_eq_in, *rd_lr_eq_use;
+
+static bool
+df_rd_lr_eq_confluence_n (edge e)
+{
+  bitmap out = &df_rd_get_bb_info (e->src->index)->rd_lr_eq_regs;
+  bitmap in = &rd_lr_eq_in[e->dest->index];
+  return bitmap_ior_into (out, in);
+}
+
+static bool
+df_rd_lr_eq_transfer_function (int bb_index)
+{
+  bitmap in = &rd_lr_eq_in[bb_index];
+  bitmap eq_use = &rd_lr_eq_use[bb_index];
+  bitmap out = &df_rd_get_bb_info (bb_index)->rd_lr_eq_regs;
+  bitmap lr_in = &df_lr_get_bb_info (bb_index)->in;
+  bitmap def = &df_lr_get_bb_info (bb_index)->def;
+  bool changed = bitmap_ior_and_compl (in, eq_use, out, def);
+  return bitmap_and_compl_into (in, lr_in) || changed;
+}
+
+static void
+df_rd_init_lr_eq_regs (bitmap all_blocks)
+{
+  unsigned int bb_index;
+  bitmap_iterator bi;
+  struct df_rd_problem_data *problem_data;
+
+  rd_lr_eq_in = XNEWVEC (bitmap_head, last_basic_block);
+  rd_lr_eq_use = XNEWVEC (bitmap_head, last_basic_block);
+
+  problem_data = (struct df_rd_problem_data *) df_rd->problem_data;
+  EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi)
+    {
+      bitmap_initialize (&rd_lr_eq_in[bb_index], &problem_data->rd_bitmaps);
+      bitmap_initialize (&rd_lr_eq_use[bb_index], &problem_data->rd_bitmaps);
+      bitmap rd_lr_eq_regs = &df_rd_get_bb_info (bb_index)->rd_lr_eq_regs;
+      bitmap_copy (&rd_lr_eq_use[bb_index], rd_lr_eq_regs);
+      bitmap_clear (rd_lr_eq_regs);
+    }
+
+  df_simple_dataflow (DF_BACKWARD, NULL,
+		      NULL, df_rd_lr_eq_confluence_n,
+		      df_rd_lr_eq_transfer_function,
+		      all_blocks, df_get_postorder (DF_BACKWARD),
+		      df_get_n_blocks (DF_BACKWARD));
+
+  EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi)
+    {
+      bitmap_clear (&rd_lr_eq_in[bb_index]);
+      bitmap_clear (&rd_lr_eq_use[bb_index]);
+    }
+  free (rd_lr_eq_in);
+  free (rd_lr_eq_use);
+}
 
 /* Free basic block info.  */
 
@@ -213,6 +302,7 @@ df_rd_free_bb_info (basic_block bb ATTRI
       bitmap_clear (&bb_info->kill);
       bitmap_clear (&bb_info->sparse_kill);
       bitmap_clear (&bb_info->gen);
+      bitmap_clear (&bb_info->rd_lr_eq_regs);
       bitmap_clear (&bb_info->in);
       bitmap_clear (&bb_info->out);
     }
@@ -262,12 +352,14 @@ df_rd_alloc (bitmap all_blocks)
 	  bitmap_clear (&bb_info->kill);
 	  bitmap_clear (&bb_info->sparse_kill);
 	  bitmap_clear (&bb_info->gen);
+	  bitmap_clear (&bb_info->rd_lr_eq_regs);
 	}
       else
 	{
 	  bitmap_initialize (&bb_info->kill, &problem_data->rd_bitmaps);
 	  bitmap_initialize (&bb_info->sparse_kill, &problem_data->rd_bitmaps);
 	  bitmap_initialize (&bb_info->gen, &problem_data->rd_bitmaps);
+	  bitmap_initialize (&bb_info->rd_lr_eq_regs, &problem_data->rd_bitmaps);
 	  bitmap_initialize (&bb_info->in, &problem_data->rd_bitmaps);
 	  bitmap_initialize (&bb_info->out, &problem_data->rd_bitmaps);
 	}
@@ -414,6 +506,12 @@ df_rd_bb_local_compute (unsigned int bb_
       df_rd_bb_local_compute_process_def (bb_info,
 					  DF_INSN_UID_DEFS (uid), 0);
 
+      /* If there are EQ_NOTES, and we're computing the LR&RD problem,
+	 we have to keep registers reaching the EQ_NOTES live.  */
+      if ((df->changeable_flags & DF_EQ_NOTES)
+	  && (df->changeable_flags & DF_RD_PRUNE_DEAD_DEFS))
+	df_rd_lr_eq_local_compute (bb_info, DF_INSN_UID_EQ_USES (uid));
+
       /* This complex dance with the two bitmaps is required because
 	 instructions can assign twice to the same pseudo.  This
 	 generally happens with calls that will have one def for the
@@ -485,6 +583,10 @@ df_rd_init_solution (bitmap all_blocks)
   unsigned int bb_index;
   bitmap_iterator bi;
 
+  if ((df->changeable_flags & DF_EQ_NOTES)
+      && (df->changeable_flags & DF_RD_PRUNE_DEAD_DEFS))
+    df_rd_init_lr_eq_regs (all_blocks);
+
   EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi)
     {
       struct df_rd_bb_info *bb_info = df_rd_get_bb_info (bb_index);
@@ -597,6 +699,11 @@ df_rd_transfer_function (int bb_index)
 	bitmap_set_range (live_defs,
 			  DF_DEFS_BEGIN (regno),
 			  DF_DEFS_COUNT (regno));
+      EXECUTE_IF_SET_IN_BITMAP (&bb_info->rd_lr_eq_regs, 0, regno, bi)
+	bitmap_set_range (live_defs,
+			  DF_DEFS_BEGIN (regno),
+			  DF_DEFS_COUNT (regno));
+
       changed |= bitmap_and_into (&bb_info->out, live_defs);
       BITMAP_FREE (live_defs);
     }
@@ -710,6 +817,7 @@ df_rd_top_dump (basic_block bb, FILE *fi
   df_rd_dump_defs_set (&bb_info->in, ";; rd  in  ", file);
   df_rd_dump_defs_set (&bb_info->gen, ";; rd  gen ", file);
   df_rd_dump_defs_set (&bb_info->kill, ";; rd  kill", file);
+  df_rd_dump_defs_set (&bb_info->rd_lr_eq_regs, ";; rd lr_eq", file);
 }
 
 
