S&P 500 posts best daily gain since early June