Earlier this year, many electric-vehicle (EV) stocks, including Tesla and NIO, hit all-time highs. Many special purpose acquisition companies (SPACs) also soared after announcing plans to merge with smaller EV makers or EV technology companies.

That buying frenzy was supported by a new breed of Robinhood investors, who got many of their investing ideas from Reddit forums and aggressive growth investors like Cathie Wood, who holds Tesla as the top position in her flagship ARK Innovation ETF.

However, many investors who chased those rallies were punished over the past three months, as rising bond yields sparked a rapid rotation from growth to value stocks. Many high-growth tech stocks also plummeted as investors pivoted from pandemic growth stories to reopening plays.

It might be tempting to buy some of those EV stocks after the recent sell-off. However, I believe it's safer to invest in diversified tech companies that will profit from the expansion of the EV market but aren't completely tethered to its future. Here are three stocks that fit the bill: Baidu (BIDU -0.09%), NVIDIA (NVDA 1.64%), and NXP Semiconductors (NXPI 0.25%).

A digital illustration of a vehicle.

Image source: Getty Images.

1. Baidu

Baidu, which owns the top search engine in China, generates most of its revenue from ads. This core business has struggled over the past two years due to competition, slower economic growth in China, tighter restrictions on certain types of ads, and the pandemic.

However, Baidu expects its advertising business to recover this year as China's economic growth stabilizes, pandemic-stricken sectors recover, and it expands its ecosystem with new services (such as Mini Programs for its mobile app and its DuerOS voice assistant).

As Baidu's advertising business recovers, it will continue to expand Apollo, its open-source software platform for autonomous cars. Apollo has already secured over 100 global partners and is the technical foundation for its robotaxi and autonomous EV businesses.

Baidu launched a new EV joint venture with the Chinese automaker Geely earlier this year and recently appointed Wei Dong, the former CEO of the ride-hailing company Shouqi Yueche, to commercialize its Apollo software. Those efforts, along with Baidu's plans to launch more Apollo-powered vehicles this year, could finally enable the tech giant to generate meaningful revenue from its automotive business.

2. NVIDIA

One of Baidu's top Apollo partners is NVIDIA, which is primarily known for its gaming and data center GPUs, but it also sells automotive chips.

An autonomous vehicle powered by NVIDIA's chips and Baidu's Apollo software.

Image source: NVIDIA.

NVIDIA's Arm-based Tegra CPUs power infotainment and navigation systems for high-end automakers like Audi and Lamborghini. They also power its Drive onboard computers for autonomous vehicles.

NVIDIA generated 3% of its revenue from automotive chips last quarter. That's just a tiny sliver of its business, and the unit faced severe headwinds last year as the pandemic disrupted the production of new vehicles. The global semiconductor shortage could further delay that recovery.

But after those headwinds wane, NVIDIA's automotive business should recover and gradually account for a larger slice of its revenue. Until then, NVIDIA should continue to generate high double-digit percentage revenue and earnings growth as it sells more gaming and data center GPUs.

3. NXP Semiconductors

NXP, one of Europe's largest chipmakers, is often overlooked in discussions about driverless and electric vehicles. However, the Dutch company became the world's largest automotive chipmaker six years ago after acquiring its rival Freescale.

NXP's automotive business, which accounted for 44% of its revenue last year, suffered a slowdown last year and offset the growth of its industrial IoT (Internet of Things) and mobile chip businesses. The softness of its communication infrastructure business exacerbated that slowdown.

But this year, analysts expect NXP's revenue and earnings to increase 23% and 58%, respectively, as its auto business recovers.

That outlook seems rosy, but the chip shortage could still throttle NXP's recovery by delaying shipments of new cars. NXP manufactures most of its own chips, but it outsources some of its production to Taiwan Semiconductor Manufacturing, the world's top contract chipmaker. As a result, its long-term recovery could still partly depend on TSMC's ability to boost its capacity and stabilize the global chip market.

That being said, NXP remains a balanced play for conservative investors who want some exposure to the automotive chip market but don't want to take outsized risks on speculative EV makers and SPACs.