Combining code motion and scheduling