S&P 500 ends near record high as AI optimism lifts chipmakers