diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c424d64ec2986381969ec5ceef28d8867db20637..cda729aa0fdc37e6e979257d32fd98f81808396c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2005-02-16  Paul Brook  <paul@codesourcery.com>
+
+	* reload1.c (emit_reload_insns): Invalidate dead input registers used
+	for reloads.
+
 2006-02-16  Bernd Schmidt  <bernd.schmidt@analog.com>
 
 	PR rtl-optimization/25636
diff --git a/gcc/reload1.c b/gcc/reload1.c
index 7bfd2a1f6aee7733d538ae9208429999acb594b2..6746c78ed58de444be4932b3db1dbdf0ba8eb368 100644
--- a/gcc/reload1.c
+++ b/gcc/reload1.c
@@ -7419,13 +7419,18 @@ emit_reload_insns (struct insn_chain *chain)
       /* If a register gets output-reloaded from a non-spill register,
 	 that invalidates any previous reloaded copy of it.
 	 But forget_old_reloads_1 won't get to see it, because
-	 it thinks only about the original insn.  So invalidate it here.  */
-      if (i < 0 && rld[r].out != 0
-	  && (REG_P (rld[r].out)
-	      || (MEM_P (rld[r].out)
+	 it thinks only about the original insn.  So invalidate it here.
+	 Also do the same thing for RELOAD_OTHER constraints where the
+	 output is discarded.  */
+      if (i < 0 
+	  && ((rld[r].out != 0
+	       && (REG_P (rld[r].out)
+		   || (MEM_P (rld[r].out)
+		       && REG_P (rld[r].out_reg))))
+	      || (rld[r].out == 0 && rld[r].out_reg
 		  && REG_P (rld[r].out_reg))))
 	{
-	  rtx out = (REG_P (rld[r].out)
+	  rtx out = ((rld[r].out && REG_P (rld[r].out))
 		     ? rld[r].out : rld[r].out_reg);
 	  int nregno = REGNO (out);
 	  if (nregno >= FIRST_PSEUDO_REGISTER)
@@ -7501,7 +7506,7 @@ emit_reload_insns (struct insn_chain *chain)
 	    }
 	  else
 	    {
-	      int num_regs = hard_regno_nregs[nregno][GET_MODE (rld[r].out)];
+	      int num_regs = hard_regno_nregs[nregno][GET_MODE (out)];
 
 	      while (num_regs-- > 0)
 		reg_last_reload_reg[nregno + num_regs] = 0;