Five years ago, who would've guessed that O'Reilly Automotive (ORLY 0.04%) would be one of the market's big winners? But its share price is up roughly 240% since then on a split-adjusted basis, crushing the S&P 500's five-year return of 106%.

How did O'Reilly do it? Well, besides having one of the catchiest jingles out there ("Oh, Oh, Oh, O'Reillyyyyyyyy...!"), the company has been rapidly opening new stores and buying back stock. Its shares just split 15-for-1 in June.

Even though its split-adjusted share price has doubled in less than three years, O'Reilly stock could double again by 2030. Here's how.

Weak auto sales are an auto parts retailer's dream

U.S. auto sales have been going through a rough patch, and recent trade policy changes seem likely to make things worse in the short term.

New tariffs on auto imports and various imported auto components have now kicked in on top of already high tariffs on automaking essentials like aluminum. This seems almost certain to boost the price of a new car by thousands of dollars. That will likely drive up used car prices as well, pushing down already weak demand even further.

That may be bad for U.S. automakers, but it's a boon for an auto parts supplier like O'Reilly. A slump in vehicle purchasing means that people hang onto their existing cars for longer. And the longer you have a car, the more likely it is that something on it -- whether it's a headlight bulb or an automatic transmission -- will need to be replaced, and O'Reilly will be happy to sell it to you (or to your mechanic).

A green arrow points upward over an image of Ben Franklin from the hundred dollar bill.

Image source: Getty Images.

Weak job numbers are an auto parts retailer's dream

Meanwhile, recent Labor Department data indicates that the U.S. job market may be softening. In its latest report, the U.S. Bureau of Labor Statistics (BLS) reported that just 73,000 jobs were created in July, far fewer than many economists anticipated. The BLS also revised the previous two months' job numbers down significantly. That matches recent anecdotal evidence that hiring has substantially slowed.

When people are unable to find a job -- or worried about hanging onto the one they have -- they're unlikely to make a major purchase like a new car, or even a used car. If hiring slows further or if the U.S. tips into a full-blown recession, many drivers may have no choice but to hang onto their existing vehicle, even if it's got problems. That may be bad for carmakers, but it's good for O'Reilly, which sells the parts needed to keep a clunker on the road.

A high valuation is a stock buyer's nightmare

One big concern for potential O'Reilly investors is how much its share price has risen. The company's trailing price-to-sales (P/S) ratio of 5.2 is already much higher than that of rivals Autozone (NYSE: AZO) or Advance Auto Parts (NYSE: AAP), which sit at 3.6 and 0.4, respectively. Its price-to-earnings (P/E) ratio has jumped to a multidecade high of 36.4, also well above that of its rivals. That said, given the company's solid track record and excellent prospects for further growth, its premium valuation makes sense.

For O'Reilly's share price to double by 2030, it would need to increase by a compound annual growth rate (CAGR) of about 15% per year. That seems achievable. In the most recent quarter, diluted earnings per share were up 11% year over year, and management projected a 3% net increase in store count for the year. Add a few additional percentage points of sales growth from weakening auto sales and a softening labor market, and you could easily get a 15% CAGR for O'Reilly stock.

Of course, nothing is guaranteed, but even if O'Reilly falls short of a five-year double, it should still end up a long-term winner for investors.