Semiconductor stocks got a big shot in the arm this year thanks to artificial intelligence (AI), which isn't surprising as chips play a central role in the proliferation of this technology by enabling the training of AI models and running inferencing applications.

This growing interest in semiconductor stocks explains why the PHLX Semiconductor Sector index jumped an impressive 43% so far in 2023. Its constituents, such as Nvidia and Advanced Micro Devices, have delivered impressive gains to investors this year with gains of 234% and 63%, respectively, which isn't surprising as both companies are on track to win big from the growing adoption of AI thanks to their graphics processing units (GPUs).

However, Nvidia and AMD are fabless semiconductor companies, which means that they only design and sell the chips. The manufacturing of these chips is outsourced to a specialist manufacturer known as a foundry. This is where Taiwan Semiconductor Manufacturing (TSM 1.26%), popularly known as TSMC, comes into play.

Why TSMC is a pick-and-shovel AI play you wouldn't want to miss

TSMC is the world's largest semiconductor foundry, with an impressive market share of 55% as of 2022, according to market research firm IDC. It is way ahead of second-placed Samsung, which controls 16% of this space. This puts TSMC in a solid position to benefit from the AI-fueled surge in semiconductor sales.

Sales of AI chips are expected to expand at an annual growth rate of 29% through 2030 and generate over $304 billion in annual revenue at the end of the forecast period. As a result, chipmakers such as Nvidia and AMD will have to invest in advanced chipmaking tools that the likes of TSMC provide. This explains why the demand for TSMC's advanced packaging equipment -- which will allow chipmakers to integrate powerful processors with faster memory to tackle AI workloads -- is surging.

Both AMD and Nvidia have been placing more orders for TSMC's chip-on-wafer-on-substrate (CoWoS) packaging solutions. The foundry giant reportedly has an existing CoWoS capacity of 8,000 wafers. This number is expected to jump to 11,000 wafers by the end of the year and to 16,000 wafers by the end of 2024, when TSMC plans to double its CoWoS capacity.

It is worth noting that TSMC decided to invest $2.9 billion in a new plant in Taiwan to ramp up its advanced packing capacity, though it won't be surprising to see the company invest more in this niche. That's because TSMC sees the demand for AI server processors increasing at an annual rate of almost 50% for the next five years.

With the advanced packaging market expected to generate almost $79 billion in annual revenue in 2028 as compared to $44 billion last year, an improvement in TSMC's share, thanks to its move to ramp up capacity, is going to be a solid tailwind for the company's business. Meanwhile, the overall semiconductor foundry market is expected to generate almost $186 billion in annual revenue in 2030, up from $104 billion last year.

Given that TSMC already controls a nice chunk of this space, and it has been gaining more share -- its market share increased by 2.4 percentage points last year -- the company's revenue is likely to improve at a nice clip, as the following chart indicates:

TSM Revenue Estimates for Current Fiscal Year Chart.

TSM Revenue Estimates for Current Fiscal Year data by YCharts.

How much upside can investors expect?

The chart above shows that TSMC's revenue could increase to $94 billion in 2025. If that's indeed the case and the stock can maintain its current price-to-sales ratio of 7, its market capitalization could increase to $658 billion within the next three years. TSMC currently has a market cap of $494 billion, which points toward a potential upside of 33%.

But don't be surprised to see the market rewarding TSMC with a more expensive sales multiple once its AI-fueled growth becomes more evident and the ongoing weakness in the company's business takes a backseat. After all, AI stocks tend to command richer multiples. That's why now would be a good time to buy shares of TSMC, as its price-to-earnings ratio of 16 is a nice discount to the five-year average earnings multiple of 23, and investors may not want to miss this deal given the potential upside on offer.