Cathie Wood, the CEO of Ark Invest, famously sold shares of Nvidia at the beginning of 2022. Since then, surging demand for the company's industry-leading artificial intelligence (AI) data center chips sent the stock screaming higher.

Wood hasn't changed her tune regarding Nvidia, but she's as confident as ever about the future of AI and its implications for the stock market. On Monday, June 12, she bought over 98,000 shares of Taiwan Semiconductor Manufacturing Co. (TSM 1.26%), also known as TSMC. The very next day, she bought over 270,000 shares of Teradyne (TER 4.79%) for Ark Invest's exchange-traded funds.

These two stocks probably don't rise to the top of your mind when you think about AI -- but they should. Without their help, Nvidia's operation would quickly cease to function.

Why Wood prefers TSMC stock to Nvidia right now

At the moment, Nvidia shares are trading at around 218 times trailing-12-month earnings, and 54 times forward-looking earnings. This implies many years of strong and uninterrupted growth, which is something we've never seen from the highly cyclical semiconductor industry.

Nvidia is one of dozens of chip designers, but it's "fabless" -- it outsources its chipmaking to other companies. And there are only a few foundries on Earth that can make its chips. When it comes to reliably producing Nvidia's most advanced semiconductors, intended for AI data centers, TSMC is often the only option.

Considering TSMC's ability to produce chips at a scale that none of its competitors can match, recent news that the foundry will raise prices should come as no surprise.

News that TSMC was getting heaps of orders from Nvidia drove the stock higher this year. Despite the run-up, it still appears reasonably valued, at around 16 times trailing earnings.

Why Wood prefers Teradyne stock to Nvidia

When fabless companies like Nvidia hire TSMC to manufacture their products, many also insist that TSMC buy test equipment from Teradyne. Semiconductor and system testing are the largest parts of its business, but Teradyne also has a relatively fast-growing robotics segment.

TSMC has been Teradyne's largest customer for years. Thanks to its robotics segment, though, Teradyne relies on TSMC for less than 10% of total revenue these days.

Teradyne's testing platform makes it fairly easy for manufacturers to run simultaneous testing of many devices in parallel; this helps retain clients and attract new ones. Diverse revenue streams make Teradyne a relatively safe bet compared to Nvidia, but it's still subject to economic cycles that affect semiconductor sales and manufacturing in general.

In the first quarter of 2023, total revenue fell 22% year over year. Investors expecting surging demand for generative AI applications such as ChatGPT also expect demand for Teradyne's testing platform to rebound. The stock is trading at around 29 times trailing-12-month earnings.

Good stocks to buy?

Before investing every penny you can find into TSMC's seemingly undervalued stock, it's important to understand that the semiconductor foundry business is hypercompetitive. TSMC is raising its prices today because it's in the lead, but this is a race that never ends.

TSM Capital Expenditures (TTM) Chart

TSM Capital Expenditures (TTM) data by YCharts.

Over the past 12 months, TSMC plowed $37.3 billion into building new factories that will make next-generation chips. That was nearly half of the company's total revenue during that period. It was also more than 100% of TSMC's total revenue in 2020.

A price that works out to 16 times trailing earnings makes TSMC look safer than it actually is right now. Government support for its competitors, Intel and Samsung, means capital expenditures will probably keep rising at a hair-raising pace for TSMC. If any of the heavy investments that TSMC makes in order to stay in the lead should fail to drive sales growth, investors who buy now could suffer heavy losses.

While Wood's been buying TSMC hand over fist, it's still a relatively small part of large portfolios. Risk-tolerant investors who still want to buy the stock should follow suit.

Teradyne is trading at a much higher multiple of earnings, but right now it's probably a safer bet for long-term investors than TSMC. Teradyne's capital expenditure budget works out to just 5% of total revenue, and it's actually fallen significantly over the past two years. If you're eager to bet on the continued popularity of generative AI applications, then following Wood and buying some shares of this stock looks like a smart move.