Semiconductor stocks have lost their wheels in 2022 following two years of solid growth as concerns over slowing chip demand, high inflation, restrictions on sales of chips to China, and the prevalent gloom in the market have dealt a crushing blow to some high-profile names this year. But there's one company that's growing at a terrific pace despite the headwinds.

Taiwan Semiconductor Manufacturing Company (TSM 1.61%), popularly known as TSMC, delivered solid third-quarter results on Oct. 13 that crushed Wall Street's expectations. The world's leading semiconductor foundry by market share also delivered healthy guidance for the current quarter that points toward sustained growth in its business.

Let's look at what's driving TSMC's growth and why this semiconductor stock could turn out to be a top long-term pick that investors may regret not buying while it is still down.

Solid semiconductor demand is driving TSMC's impressive growth

TSMC's Q3 revenue increased 36% year-over-year to $20.2 billion, easily beating the consensus estimate of $19.4 billion. The company attributed the solid growth to the healthy demand for chips manufactured using the advanced 5-nanometer (nm) and 7-nm processing nodes. TSMC got 54% of its total revenue from selling chips based on these nodes.

That's not surprising, as chips made using smaller process nodes are more powerful and efficient, and TSMC's customers are lining up to buy them. This was evident from the 25% quarter-over-quarter growth in the company's revenue from the smartphone segment, which produced 41% of TSMC's total revenue last quarter.

Apple was TSMC's largest customer last year, accounting for a quarter of the latter's top line. In 2022, it is estimated that TSMC's revenue from Apple could jump 25% to $17 billion as the iPhone maker has tapped the Taiwanese foundry giant for the 4nm chips that power the iPhone 14 Pro and Pro Max models. Supply chain gossip also suggests that Apple has placed chip orders for the next two generations of the iPhone with TSMC.

TSMC's advanced chips are helping it mint more money. The A16 Bionic chip in the iPhone 14 Pro and the Pro Max reportedly cost $110 to manufacture, which is nearly 2.4 times costlier than last year's processor. This explains why TSMC's margin expanded substantially last quarter. The company's gross margin increased to 60.4% in Q3 from 51.3% in the prior-year period. The net profit margin was up to 45.8% from 37.7% a year ago.

TSMC's margins could expand further in the future, as the company's move to smaller process nodes could help improve yields and lower production costs.

More importantly, Apple is just one of the many impressive long-term catalysts TSMC is sitting on. The company's revenue from the Internet of Things (IoT) and the automotive businesses were up 33% and 15%, respectively, in Q3 compared to the second quarter. These markets present secular growth opportunities for the company.

The automotive market, for instance, is expected to clock 11% annual growth through 2027 and generate nearly $67 billion in annual revenue, compared to $35 billion last year. The IoT chip market, on the other hand, could grow at nearly 15% a year through 2027. TSMC is in a solid position to make the most of these two markets thanks to its dominant market share in the foundry space.

Buying the stock is a no-brainer right now

TSMC's fourth-quarter guidance should be enough to put any concerns of a semiconductor slowdown to rest. The foundry giant anticipates $20.3 billion in revenue this quarter at the midpoint of its guidance range, along with an operating profit margin of 50%. TSMC delivered $15.7 billion in revenue in the prior-year period, along with an operating profit margin of 41.7%.

So the company's top line could jump 29% year-over-year this quarter, while the margin expansion could lead to solid earnings growth. TSMC is expected to sustain a healthy earnings growth rate in the long run. Analysts anticipate 22% annual earnings growth from TSMC for the next five years, which isn't surprising given the massive opportunity in the semiconductor market.

That's why investors looking to add a top semiconductor stock to their portfolios may want to buy TSMC following its 47% slide in 2022. The stock is trading at just 14 times trailing earnings and 11 times forward earnings -- which is a discount to the S&P 500's trailing and forward earnings multiples of 18 and 16, respectively -- indicating that TSMC is a bargain right now and investors may not want to miss this opportunity to buy before it starts soaring.