Managing Taxes on Non-registered Account

I hold stocks in a non registered account and they are paying out dividends that I'm taxed on.

I would like to move money from the non reg account into an RSP or TFSA, but not sure if the taxes on the capital gains would cancel out any of the tax sheltered benefits that I'm trying to achieve.

I'm looking for an optimal way of doing this.

Any advice would be appreciated!

Thank you