fix PR5978 by peeling the loop so that we avoid shifting the