Yes. It can be used to offset capital gain from the sale of second home.
For more information check Capital Gains and Losses