Taiwan Semiconductor Manufacturing Company (TSM -0.34%), the world's largest pure-play contract chipmaker, is often considered a solid investment on the semiconductor market. It's generated a total return of more than 430% over the past five years, while the S&P 500 only delivered a total return of about 120%.

TSMC's revenue rose 25% (31% in U.S. dollar terms) in 2020, while its earnings per share increased 50%. Analysts expect its revenue and earnings to rise 23% and 17%, respectively, this year as it profits from the world's insatiable appetite for new chips. Its stock has nearly doubled over the past 12 months, but it still looks reasonably valued at 27 times forward earnings.

A silicon wafer

Image source: Getty Images.

Those numbers suggest TSMC is still a great investment, but let's dig deeper into three compelling reasons to buy the stock -- as well as one bright red flag that investors can't afford to ignore.

1. The world's most advanced chipmaker

In the past, many chipmakers manufactured their own chips with in-house foundries. But as chips became smaller and more difficult to manufacture, many chipmakers either closed or spun off their capital-intensive foundries and outsourced their production to third-party foundries like TSMC.

Today, only three foundries can mass produce chips that are 10nm or smaller: TSMC, Samsung, and Intel (INTC 0.64%). TSMC remains ahead of both companies in the "process race" to create smaller and more power-efficient chips: It's currently mass producing 5nm and 7nm chips, and it plans to start mass producing 3nm chips in the second half of 2022.

TSMC's technological lead, which it's gained from more than three decades of expertise and investments, makes it the top choice for "fabless" chipmakers like Apple, AMD , Qualcomm, and NVIDIA. These strengths make TSMC the world's most important chipmaker and a linchpin of the global semiconductor market -- and it will continue growing as new devices require more powerful chips.

2. A well-diversified business

TSMC generated 41% of its revenue from 5nm and 7nm chips last year. The rest of its revenue came from older and larger nodes, which are still widely used for lower-end and mid-range chips.

TSMC also serves a wide range of markets. In 2020 it generated 48% of its revenue from smartphone chips, 33% from HPC (high-performance computing) chips, 8% from IoT (Internet of Things) chips, 4% from DCE (digital consumer electronics), 3% from automotive chips, and the rest from other industries.

All of those markets, except for the pandemic-stricken auto market, expanded during the year. This year, its smartphone business should continue expanding as new 5G phones hit the market, the expansion of data centers and edge computing services should bolster its sales of HPC and IoT chips, and the automotive sector should gradually recover as the pandemic passes.

That diversification has insulated TSMC from industry-specific downturns in the past, and should continue to shield investors from unpredictable challenges in the future.

3. Maintaining its lead in the process race

TSMC intends to maintain its technological lead by boosting its capex from $17.2 billion in 2020 to about $30 billion in 2021. It also intends to spend $100 billion over the next three years to boost its production capacity.

Samsung's chipmaking capex should remain roughly flat year-over-year at $28.1 billion this year, according to IC Insights, while Intel recently allocated $20 billion toward the expansion of its first-party foundry in Arizona.

TSMC is spending a lot of money, but analysts expect its earnings to continue to rise even as it boosts its capex to historic levels. It should also continue its 27-year-streak of uninterrupted dividend payments.

One reason to sell TSMC: The geopolitical risk

The single greatest risk to TSMC is its location. It's based in Taiwan, which has become a flashpoint for military and economic tensions between the U.S. and China. The Trump Administration forced TSMC to stop manufacturing chips for Huawei last year, and the Biden Administration has been trying to convince TSMC to manufacture its most advanced chips in the U.S.

The Biden Administration has also proposed to subsidize domestic chipmakers like Intel with the $50 billion CHIPS act. That support might make it easier for Intel to catch up to TSMC and Samsung in the process race, and make its domestic foundries viable alternatives to those of the two Asian giants.

These tensions could also force Chinese chipmakers to rely more heavily on SMIC, China's largest contract chipmaker, even though it remains several chip generations behind TSMC.

If push comes to shove, Chinese regulators could retaliate against TSMC's plants in China, which manufacture much older chips than its plants in Taiwan. Chinese chipmakers have also been trying to poach top TSMC engineers to advance the country's domestic chipmaking efforts.

China probably won't invade Taiwan with a military force anytime soon, but all these smaller strategic moves on both sides of the Pacific could impact TSMC's long-term growth.

The key takeaways

I personally believe TSMC's strengths still outweigh the geopolitical risks. However, investors should be well aware of these challenges before lauding TSMC as the perfect semiconductor stock.