Shares of Advanced Micro Devices Inc. surged Wednesday, to snap their longest losing streak in 18 months, as upbeat semiconductor industry data helped spark a broad rally in chip stocks.

AMD rival Nvidia Corp.’s stock also bounced sharply, as a partnership announced with China’s Baidu Inc. and upbeat news from current car sector partner Volvo combined with the bullish industry data to help fuel the gains.

The Semiconductor Industry Association said late Monday that global chip sales in May jumped 22.6% from a year ago to $31.9 billion, the biggest year-over-year leap since September 2010. All major regional markets witnessed growth of more than 15%, with the Americas pacing the world with a 30.5% increase.

The PHLX Semiconductor Index SOX, -1.51% (SOX) rallied 2.1%, outperforming the broader stock market by a wide margin. The S&P 500 index SPX, -1.11% was up just 0.2% while the tech-friendly Nasdaq Composite Index COMP, -1.07% tacked on 0.7%.

AMD’s stock AMD, -2.11% shot up 8.6%, to pace the S&P 500 gainers. Volume was heavy at 98.8 million shares in recent trade, more than the full-day average of 85.4 million shares, and enough to make the stock the most actively traded on the Nasdaq exchange.

FactSet, MarketWatch

Before the rally, the stock had tumbled 15.5% amid a seven-session losing streak. That was the longest such stretch since the seven-session streak ending Jan. 8, 2016, as investors fretted over increasing competition from Nvidia.

Don’t miss: AMD’s stock falls as Nvidia’s upcoming cryptocurrency GPUs pose a threat.

Nvidia’s stock NVDA, -2.20% ran up 2.7% to snap a three-session losing streak, and just made the S&P 500’s top-10 gainers list. The company announced earlier Wednesday that it has entered into a partnership with China’s internet search giant Baidu to expand both companies’ artificial intelligence-based offerings, including the development of self-driving cars and home assistance products.

Separately, Chinese-owned automotive group Volvo announced that it will phase out the conventional combustion engine within two years. Nvidia had unveiled last week a joint venture with Volvo to develop industry-leading self-driving technology.

Will Other Car Makers Follow Volvo's Switch to Electric?

Among other chip makers, Micron Technology Inc.’s stock MU, -0.47% rallied 4.7% to the be S&P 500’s second-biggest gainer. It has climbed 39% year to date, boosted by better-than-expected results, upbeat outlooks and optimism ahead of new smartphone launches in the fall.

See also: Micron benefits from high memory prices and new phones in the fall.

Elsewhere, shares of chip industry leader Intel Corp. INTC, -0.85% rose 2.6%, Analog Devices Inc. ADI, -0.50% advanced 2.1%, Texas Instruments Inc. TXN, -1.23% gained 0.7%, Qualcomm Inc. QCOM, -3.64% tacked on 0.9%, Applied Materials Inc. AMAT, -0.33% rallied 0.9% and Broadcom Ltd. AVGO, -1.69% added 0.8%.

The SOX has now climbed 14.9% year to date, and 54.9% over the past year, while the S&P 500 has gained 8.7% so far this year and 16.5% over the past 12 months.