Warren Buffett's Berkshire Hathaway (BRK.B 0.47%) (BRK.A 0.43%) piled into shares of Taiwan Semiconductor Manufacturing (TSM -1.75%) in 2022, buying $4.1 billion of the stock over the span of a few months. The move made sense: TSMC is the global leader in the business of manufacturing advanced chips. For customers like Apple that need hundreds of millions of cutting-edge chips each year, there is no viable alternative to TSMC right now.

Just a few months after betting billions on TSMC, Buffett turned around and sold the bulk of Berkshire's holdings. A regulatory filing in February disclosed that Berkshire's position in TSMC was reduced by about 86% in the fourth quarter of last year. Buffett's not one to make snap decisions, so this move was unusual.

Earlier this month, Berkshire disclosed that it had dumped the remaining shares of TSMC in its portfolio.

Buffett is worried about Taiwan

TSMC is the overwhelming leader in the third-party foundry business. As manufacturing advanced chips has grown increasingly capital intensive and technically complex over the years, companies like IBM and AMD that traditionally made their own chips have given up on manufacturing to focus on chip design. This has left very few companies capable of churning out high-performance chips.

TSMC held a 58.5% share of the global foundry market in the fourth quarter of 2022, according to TrendForce. The next largest player, Samsung, managed to snag just 15.8% of the market. TSMC has built a lead, both technologically and in terms of capacity, that has made it the default choice for much of the semiconductor industry.

Barriers to entry in the semiconductor manufacturing industry are enormous, which will make dethroning TSMC an expensive affair for any competitor. Building a new foundry capable of making advanced chips is a multiyear process that can cost as much as $20 billion. To maintain an edge, a semiconductor manufacturer must continually move to more advanced manufacturing processes, shrinking down the size of features and piling on additional complexity.

It's no wonder, then, that Buffett was drawn to TSMC last year. But ultimately, the quality of the business couldn't overcome its location. TSMC is based in Taiwan, and the future of the island is mired in uncertainty. China claims Taiwan as its own, and an attempt at reunification is a real possibility. What happens to TSMC in this scenario is hard to predict.

This uncertainty seems to be a driving force behind Buffett's decision to backtrack on TSMC. In an interview in April, Buffett said that geopolitical tensions between China and Taiwan were a factor in the unexpected sale. Buffett appears to be uncomfortable having billions in Berkshire's cash tied up in an investment that would ultimately be a bet that the status quo in Taiwan remains unchanged.

TSMC faces other risks

While Buffett is mostly concerned about location, TSMC is suffering from a slowdown in demand just as Samsung and Intel are racing to catch up.

Intel has made building out a foundry business one of the pillars of its turnaround effort, and its plan to bring five new manufacturing nodes to volume production in the span of four years is so far on track. Meanwhile, Samsung's foundry arm aims to catch up to TSMC technologically within five years. Both companies will be spending tens of billions of dollars to achieve those goals.

TSMC is at no immediate risk of being overtaken, given the timelines involved in getting new semiconductor manufacturing facilities up and running. But it seems likely that the company's dominance will be eroded to a degree over the next decade.

Shares of TSMC are down sharply from their pandemic-era high, and the stock appears reasonably priced, trading for around 18 times the average analyst estimate for 2023 earnings. But Buffett believes the risks are too great, and investors should certainly not ignore the Oracle of Omaha.