Yes, do avoid selling funds for a loss if you intend to buy back the same funds within the IRA within 30 days (before or after). Transferring funds to a tax-deferred IRA can be a great idea even if you have to realize some gains to do it.
Suppose you're in the 25% tax bracket and you want to fill up your IRA. All you have in your taxable account are shares that have doubled in value since you bought them. You sell $5,500 worth, realizing a capital gain of $2,750. You pay 15% capital gains tax ($412.50) on this sale. You then put $5,500 in your IRA, saving tax on the full sum at your 25% marginal rate ($1,375). This leads to a tax savings of $962.50 even if you have to sell shares that have doubled in value since you bought them! Selling losers will of course be better, provided you avoid invoking the wash sale rule.