US stock market notches biggest gain in 8 months