US stocks extended gains on President Donald Trump’s retreat from tariff threats while traders’ appetite for artificial intelligence bets returned.