S&P 500, Nasdaq Post Best Q2 Gains in 6 Years Amid AI Boom