CodeGen/LiveVariables: hoist out code in nested loops

This makes runOnMachineFunction vastly more readable.