--- gcc/sel-sched-ir.c.jj	2010-07-09 13:44:24.000000000 +0200
+++ gcc/sel-sched-ir.c	2010-08-20 14:14:57.000000000 +0200
@@ -4326,7 +4326,7 @@ sel_bb_head (basic_block bb)
       note = bb_note (bb);
       head = next_nonnote_insn (note);
 
-      if (head && BLOCK_FOR_INSN (head) != bb)
+      if (head && (BARRIER_P (head) || BLOCK_FOR_INSN (head) != bb))
 	head = NULL_RTX;
     }
 
--- gcc/testsuite/gcc.dg/pr45353.c.jj	2010-08-20 14:17:44.000000000 +0200
+++ gcc/testsuite/gcc.dg/pr45353.c	2010-08-20 14:17:24.000000000 +0200
@@ -0,0 +1,9 @@
+/* PR rtl-optimization/45353 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fschedule-insns -fselective-scheduling" } */
+
+void
+foo ()
+{
+  __builtin_unreachable ();
+}
