Moved invariant hoisting to the end of the optimization phases to eliminate context problems when scalarizing (definitions useful for scalarization are correctly hoisted, hoisting was being done too early)