Optimize register allocation