Heegaard and regular genus agree for compact 3-manifolds