diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c84f1a6a4346c3e3e1c106d583330bcf93d6045b..9992c733fde3cd46f2f8c4964525b70f72810654 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,7 @@
+2009-06-02  Alexandre Oliva  <aoliva@redhat.com>
+
+	* combine.c (move_deaths): Compare LUIDs within the same BB only.
+
 2009-06-02  Alexandre Oliva  <aoliva@redhat.com>
 
 	* common.opt (fdump-unnumbered-links): New.
diff --git a/gcc/combine.c b/gcc/combine.c
index 7cdf396a66cda166869815ded24e063a5b5a31ab..0f8b08741435077d70f4189d125f179221e15545 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -12144,6 +12144,7 @@ move_deaths (rtx x, rtx maybe_kill_insn, int from_luid, rtx to_insn,
 	return;
 
       if (where_dead
+	  && BLOCK_FOR_INSN (where_dead) == BLOCK_FOR_INSN (to_insn)
 	  && DF_INSN_LUID (where_dead) >= from_luid
 	  && DF_INSN_LUID (where_dead) < DF_INSN_LUID (to_insn))
 	{