The global chip shortage has been bad news for people trying to buy cars and companies looking to manufacture appliances. But it has been great news lately for investors in semiconductor stocks, some of which have been performing at the top of the S&P 500 over the past month.

Shares of Nvidia Corp. have gained 48% over the past month, while shares of Qualcomm Inc. have risen 40% and shares of Advanced Micro Devices Inc. have added 34%. The S&P 500, by comparison, has risen 3.9% over that time.

For...

The global chip shortage has been bad news for people trying to buy cars and companies looking to manufacture appliances. But it has been great news lately for investors in semiconductor stocks, some of which have been performing at the top of the S&P 500 over the past month.

Shares of Nvidia Corp. have gained 48% over the past month, while shares of Qualcomm Inc. have risen 40% and shares of Advanced Micro Devices Inc. have added 34%. The S&P 500, by comparison, has risen 3.9% over that time.

For months the global semiconductor shortage, driven by factors on both the demand and supply sides of the economy, has limited production of cars and affected makers of home appliances, heavy equipment and data servers. In recent weeks, reports from semiconductor companies during earnings season have spurred analysts’ expectations that demand for chips will exceed supply for even longer.

Nvidia has seen business boom during the pandemic amid rising demand for videogames and digital services that run on data centers.

Photo: David Paul Morris/Bloomberg News

Three months ago, semiconductor companies generally expected that supply and demand might reach a balance by the middle of 2022, said Chris Caso, an analyst covering semiconductors at Raymond James. Earnings season shifted that forecast further out.

“When we talk about the supply and demand balance, which is where we kind of get back to normal, we probably are not going to see normal for most of 2022,” Mr. Caso said. He said the imbalance might even stretch into 2023.

SHARE YOUR THOUGHTS

What is your outlook for semiconductor stocks? Join the conversation below.

The group of stocks got another boost this past week after Nvidia reported higher-than-expected sales and earnings. Business has boomed since the pandemic drove up demand for videogames and digital services that run on data centers. The company’s shares rose 8.2% Thursday and 4.1% Friday.

Such strong financial results have buoyed the group. Analysts expect that earnings from semiconductor and semiconductor-equipment companies in the S&P 500 grew 56% in the third quarter from a year earlier—more than the 40% profit growth projected from the full membership of the stock index, according to FactSet. Sales growth from the group is also expected to exceed that of the S&P 500.

“You keep reading about all the shortages and the problems that are happening in the auto industry—that’s kind of the poster child for the shortages—but the sector as a whole is actually pretty healthy in terms of revenue and earnings growth,” said Daniel Morgan, senior portfolio manager at Synovus Trust Co.

After two straight months of declines, industrial production of motor vehicles rose 18% in October, according to Federal Reserve data released Tuesday. 

Qualcomm shares rose to records this week after the company’s chief executive shared ambitious targets for his plan to diversify from cellphone chips into sales for cars and connected devices.

Semiconductor stocks also have benefited from expectations that economic growth will reaccelerate after a slowdown caused by the Delta-driven surge in Covid-19 cases and supply-chain bottlenecks.

“The semiconductors, they’re basically like cogs in the machine, meaning industrial production or auto production,” said Diane Jaffee, a senior portfolio manager on TCW’s relative value team. “If those machines are not cranking at a steady pace, they are much more subject to big swings up and big swings down in terms of their demand.”

The number of semiconductors in a modern car, from the ignition to the braking system, can exceed a thousand. As the global chip shortage drags on, car makers from General Motors to Tesla find themselves forced to adjust production and rethink the entire supply chain. Illustration/Video: Sharon Shi

Write to Karen Langley at karen.langley@wsj.com