The stock market soared last week thanks to better-than-expected inflation numbers. Those hefty gains have no doubt prompted some investors to begin thinking about the possibility of sustained momentum.

To be sure, it's too soon to predict that the stock market has indeed begun a rebound that won't fizzle out. But it's not too early to be ready in case this scenario does happen. With that in mind, here are three stocks to buy hand over fist in a big stock market rally.

1. Amazon

Every time the S&P 500 rallied by at least 5% this year, Amazon (AMZN -1.14%) stock performed even better. There are several reasons to think that the e-commerce and cloud-hosting giant could keep this trend going.

For one thing, a major stock market rally would be highly unlikely without underlying improvement in economic conditions. Amazon CFO Brian Olsavsky noted in the company's Q3 conference call that more cloud customers are trying to control costs with the overall economic uncertainty. These customers would probably regain at least some of their confidence if the economy improves (especially if inflation declines). That would likely result in stronger growth for Amazon Web Services.

Of course, an improving economy would also be great news for Amazon's other businesses. While AWS is the key growth driver for the company, it only generates 16% of total sales.

Also, Amazon stock is down a lot more now than it has been earlier this year. Shares have even fallen the most from the peak since the Great Recession. If the overall stock market rebound picks up steam, you can bet that Amazon will bounce back in a huge way.

2. Enphase Energy

Enphase Energy (ENPH -2.57%) stands out as another stock that's delivered stronger gains than the S&P 500 in previous rallies of 5% or more this year. The prospects for the stock look pretty good even if the stock market doesn't take off.

Investors bailed on several electric vehicle (EV) and solar stocks, including Enphase, earlier this month. One reason behind the sell-off was the belief that the GOP could regain control of the U.S. Congress. Republicans are viewed as less supportive of the EV and solar industries than Democrats are. However, the expected "red wave" didn't happen. 

Enphase revealed in its Q3 update that Q4 bookings are easily beating the high end of its guidance range. The company hinted that the momentum might extend into next year. It also plans to launch its third-generation IQ battery for home solar storage in 2023. 

The main knock against Enphase is its valuation. Shares currently trade at nearly 61 times expected earnings. But if the stock market takes off, investors will probably focus more on Enphase's growth opportunities than its valuation.

3. Paycom Software

Paycom Software (PAYC -1.06%) has also beaten the S&P 500 during previous significant rallies in 2022. Can the stock continue to do so if we have another big market move? Probably so.

The company is a leading online payroll and human resource technology provider. It stands to reason that when many companies are cutting staff, Paycom's business suffers. The risk of a worsening economy is probably the main reason for investors to be cautious about the stock.

But, as mentioned in the discussion about Amazon, a major stock market rally would almost certainly dovetail with an improving economic outlook. Employers would be less likely to make further significant lay-offs if the economy appears to be getting better. That would be great news for Paycom.

As is the case with Enphase, valuation is a concern with Paycom. The software company's shares trade at nearly 48 times expected earnings. However, Paycom should be able to continue delivering strong revenue and earnings growth going forward. Whenever the bulls take charge of the stock market, Paycom is likely to be one of the bigger winners.