Optimized register allocation by moving a costly calculation outside