It is impossible to predict the future, especially in the stock market, but historical patterns do suggest certain outcomes are more likely than not. For instance, analysis of trading data going back to 1971 shows the Nasdaq Composite has risen an average of 19% in the year following a market recovery year like the one that occurred in 2023. Investors looking to buy stocks in 2024 stand to benefit significantly if past trends hold.

Two semiconductor giants -- Nvidia (NVDA -0.79%) and Advanced Micro Devices (AMD 0.09%) -- could perform particularly well if this Nasdaq uptrend happens. That's because they are also likely to be beneficiaries of the generative artificial intelligence (AI) megatrend that gained momentum in 2023 and shows no signs of slowing. Let's take a closer look at these two stocks with historic trends providing them game-changing tailwinds.

Tense person watching his stock performance.

Image source: Getty Images.

1. Nvidia

Stocks that rise substantially in a relatively short timeframe can be intimidating. Investors don't always have clear indications that the growth will continue. After its share price jumped by a whopping 231% over the last 12 months, Nvidia is the exception here. It isn't too late to bet on the market leader because its long-term AI opportunity is just getting started. Compared to its potential, Nvidia's valuation remains reasonable.

Unlike some other AI stocks, Nvidia's 2023 rally was based on fundamentals, not hype. Fiscal 2024 third-quarter revenue (for the period ending Oct. 29, 2023) soared by a jaw-dropping 206% year over year to $18.12 billion, driven by relentless demand for its flagship H100 chips to power and run generative AI applications. And even though Nvidia will face more competition over the coming years, its economic moat is strong because of its massive developer community, which has built software and servers optimized around its hardware.

Nvidia's AI efforts also include the automotive industry. Just this month management announced a partnership with Mercedes Benz Group to work on self-driving cars. While a fully functional version of this technology could be years away, it highlights Nvidia's potential to expand and diversify the use cases for its chips through continued innovation.

Despite all these incredible tailwinds going into 2024 and beyond, Nvidia trades for a forward price-to-earnings (P/E) multiple of just 27, which is slightly lower than the Nasdaq average P/E of 29.

2. Advanced Micro Devices

Since it acquired ATI Technologies in 2006, AMD has competed with Nvidia in the consumer graphics processing unit (GPU) market for video game graphics, typically aiming for affordable pricing and solid performance against its cutting-edge rival. Now, it can use these same strategies to claim a slice of the much more lucrative opportunity in AI-related chips.

According to AMD's CEO Lisa Su, the $45 billion AI chip market could soar to $400 billion by 2027. To tackle this opportunity, the company has released its family of MI300X GPUs designed to compete with Nvidia's H100 on tasks including training and running generative AI applications.

So far, new AI chips have had a muted impact on AMD's results, with third-quarter revenue up by just 4% year over year to $5.8 billion. However, the company expects the new products to generate additional sales of $2 billion in 2024. And this could rapidly scale as it increases production.

With a forward price-to-earnings (P/E) multiple of 39, AMD stock would be considered expensive given its modest growth rate. But investors who buy it now are betting on what performance could look like over the coming years if the AI market reaches even a fraction of what are some lofty projections.

Which stock is better for you?

In 2024 and beyond, Nvidia and AMD will enter direct competition in the market for AI data-center chips. But this isn't necessarily a zero-sum game because the overall market is growing incredibly fast, and both companies have plenty of room to establish their respective niches.

With that said, Nvidia stock is trading significantly cheaper than its rival from a valuation perspective. And while it isn't too late to bet on either company's long-term potential, AMD will have to work much harder to justify its premium.