Shares of Taiwan Semiconductor Manufacturing (TSM 1.26%) -- otherwise known as TSMC -- dipped 5% last week after reporting a revenue decline and margin compression for the second quarter of 2023. The leading producer of computer chips worldwide is seeing demand wane after the chip supply shortages of 2021 turned into a glut.

Investors have bid up computer chip stocks such as TSMC this year on the back of the artificial intelligence (AI) boom, which requires an immense amount of computing power to train and run. The iShares Semiconductor ETF is up 47.5% in 2023, outpacing the S&P 500's (still impressive) return of 19%.  

SOXX Chart

SOXX data by YCharts

AI is not big enough (yet)

In U.S. dollars, TSMC's revenue was within its previous guidance range but still fell 13.7% year over year in Q2 to $15.7 billion. This quarter had a tough year-over-year comparison, as TSMC's business was absolutely booming at the beginning of 2022, with revenue growing 36.6% year over year in Q2 last year.

Since TSMC is a manufacturing business, it has a lot of operating leverage. This can work in the opposite direction when sales decline, which happened this quarter. The company still put up a strong 42% operating margin in Q2 2023, but this was down from 49% a year ago. 

As the primary manufacturer of semiconductors for the leading AI chipmaker Nvidia, some investors may be surprised to see revenue and profits contracting for TSMC. Isn't AI the next big technology boom? Shouldn't customers such as Nvidia, Microsoft, and Alphabet be clamoring for new computer chips from TSMC? Apparently, they are, but advanced AI chips only make up a small segment of TSMC's overall business at the moment.

On the Q2 conference call, management said that advanced AI semiconductors account for just 6% of the company's revenue, or under $1 billion last quarter. However, management is expecting this segment to grow revenue at a 50% compound annual growth rate (CAGR) for the next five years.

This would bring its quarterly AI segment revenue up to over $7 billion, or more than 7x in five years. While not material to TSMC's business today, AI could have a huge impact on its revenue growth trajectory.

Capital expenditures and cash flow

In order to make room for this growing AI demand, TSMC needs to build more factories for its customers. It just announced a new $2.9 billion advanced facility in Taiwan, for example.

TSMC is a highly capital-intensive business, spending $8 billion on facility upgrades just in the second quarter, which actually caused its free cash flow to turn negative even with profit margins above 40%. For the full year, TSMC now expects to spend $32 billion on capital expenditures, which is the low end of its prior guidance.

At first, you might take this as a good sign, given that more cash will now be available for TSMC to return to shareholders. However, TSMC always invests in new facilities in anticipation of future customer demand, making capital expenditures a proxy for future revenue growth.

Lowered guidance was likely taken as a negative sign for investors and could be why the stock dropped after releasing Q2 results.

While growing capital expenditures is typically a good thing for TSMC, there are some concerns about cost overruns at the company's new plant being built in the United States.

The company has committed tens of billions of dollars to build manufacturing in Arizona, and is apparently seeing much higher costs and a shortage of workers compared to its facilities in Taiwan. Over the long term, if these increased costs persist, TSMC could see even further margin compression.

Competitive advantage widening?

While investors should temper their expectations on AI in the near term and track cost overruns at overseas manufacturing plants, TSMC looks to be in a great position from a competitive standpoint. It is one of the few companies in the world that has the technological expertise to produce ultrafast computer chips that every technology giant -- from Apple to Tesla -- is clamoring for.

This advantage should widen even further in the next couple of years when TSMC brings its ultra-advanced 3-nanometer chip platform into production, which no other chip company has gotten close to achieving. Apple is planning to be the first customer for these next-generation semiconductors, which I'm sure they are paying a pretty penny for.

TSMC stock doesn't look expensive after its recent drop, with a trailing price-to-earnings ratio (P/E) of just 15. This is well below the market average of 26. If TSMC can return to growing revenue in the next five years due to the AI boom, forward returns for shareholders will likely outpace the overall market.

TSM PE Ratio Chart

TSM PE Ratio data by YCharts

The long-term potential for TSMC looks great. It is also trading at a cheap earnings multiple. But any bullish investor should remember TSMC is based in Taiwan, one of the world's primary geopolitical hotbeds.

If China-U.S. tensions get worse or turn violent, TSMC's facilities on the island nation could be disrupted. That doesn't mean you should avoid buying shares, but understand that investing in TSMC comes with some major risks.