As long as you maintain your H1 status, that means, do not change job, you can come back with H1 visa. Even if you are at the last stage of green card application -I485, you can do this.