A Myers-type theorem and compact Ricci solitons