The S&P 500 reached an all-time high Tuesday, up more than 14% since January. Energy companies benefited from higher oil prices after the war in Iran, while investors backed artificial-intelligence firms. The Russell 2000 fell nearly 8% over two months.