diff --git a/compiler/pack.lisp b/compiler/pack.lisp
index da60062a53819698b8a81deb30c1f849f6c73648..07ac4b133f279891a48f9429336a972dfdd52434 100644
--- a/compiler/pack.lisp
+++ b/compiler/pack.lisp
@@ -146,10 +146,12 @@
 ;;;
 (defun ir2-block-count (component)
   (declare (type component component))
-  (1+ (ir2-block-number
-       (block-info
-	(block-next
-	 (component-head component))))))
+  (do ((2block (block-info (block-next (component-head component)))
+	       (ir2-block-next 2block)))
+      ((null 2block)
+       (error "What?  No ir2 blocks have a non-nil number?"))
+    (when (ir2-block-number 2block)
+      (return (ir2-block-number 2block)))))
 
 
 ;;; Init-SB-Vectors  --  Internal