Taiwan Semiconductor Manufacturing (TSM 1.26%) and Micron Technology (MU 2.92%) both represent promising ways to invest in the growth of the semiconductor market. TSMC (as it's often called) is the world's largest contract chipmaker, producing chips for Apple, AMD, and Nvidia, among others. Micron is one of the world's leading manufacturers of DRAM and NAND memory chips.

Both chipmakers struggled in 2023 as the PC and smartphone markets cooled. But their stocks rallied over the past 12 months in anticipation of their cyclical recoveries and the expansion of the artificial intelligence (AI) market. Should investors buy either of these semiconductor stocks as they hover near their all-time highs?

Two silicon wafers.

Image source: Getty Images.

TSMC expects its growth to accelerate this year

In 2023, TSMC's revenue declined 4.5% in Taiwan dollars (9% in U.S. dollar terms), its gross margin shrank 520 basis points to 54.4%, and its earnings per share (EPS) tumbled 17.5%. That slowdown was caused by three major challenges.

First, the 5G upgrade cycle ended and consumers bought fewer smartphones. Second, the PC market cooled off after the pandemic ended. Lastly, the macro headwinds drove many companies to rein in their spending on big data center upgrades.

But in 2024, analysts expect TSMC's revenue and EPS to grow 23% and 19%, respectively, in Taiwan currency. That acceleration should be driven by the rapid expansion of the AI market, the stabilization of the smartphone and PC markets, and the increased production of its latest 3-nanometer chips. Based on those expectations, the stock still looks reasonably valued at 20 times forward earnings.

But looking beyond 2024, TSMC could face tougher challenges as Intel upgrades its foundries. The latter company believes it can catch up to TSMC in the "process race" to manufacture smaller and denser chips by 2025 -- and that effort is being supported by billions of dollars in government subsidies in the U.S. and Europe.

Intel is also directly challenging its rival with its third-party foundry services. TSMC still has the advantage, but it shouldn't turn a blind eye to Intel's efforts.

Micron has passed its cyclical trough

Micron's revenue plunged 49% in fiscal 2023 (which ended last August), its adjusted gross margin turned negative, and it posted a net loss for the full year. Like TSMC, Micron faced a rough cyclical slowdown as the PC and smartphone markets cooled off.

But it endured a steeper sales decline than TSMC because its business was less diversified and many of its customers had accumulated an excess inventory of memory chips over the past few years. Its sales in China also declined last year after the country banned its key infrastructure companies from using its memory chips.

But just like TSMC, Micron expects its prospects to brighten this year as the PC and smartphone markets stabilize, the industrial and auto markets expand, and the growth of new generative AI platforms drives more data centers to upgrade their memory chips. It should also face easy year-over-year comparisons in the Chinese market.

Micron controls a smaller slice of the DRAM and NAND markets than Samsung and SK hynix, but it usually produces denser and more power-efficient chips. That technological edge should help it keep pace with its larger rivals.

For fiscal 2024, analysts expect Micron's revenue to rise 47% as it significantly narrows its net loss. It's not expected to return to profitability until fiscal 2025, but its stock still looks reasonably valued at less than five times this year's sales.

The better buy: TSMC

TSMC and Micron are both solid long-term investments. But if I had to choose one over the other, I would pick TSMC simply because it's bigger, better diversified, and more profitable. TSMC is also a clear market leader and a linchpin of the semiconductor sector, while Micron is still an underdog growing in the shadow of its larger competitors.