US indices rally as S&P 500 posts biggest gain since March