Department store chain Dillard's has swung to a second quarter profit after improving its merchandise gross margin performance.