Unify the fallback codepath for getting prefix bits into a macro

This avoids having to know the details about when the optimized
codepath is available at the place where it's used.