As an auto parts retailer, O'Reilly (ORLY -0.60%) provides an essential service to car drivers who need to get their vehicles fixed no matter what the economy has in store. The company has performed well in past recessions and could repeat the feat if the U.S. is currently in a recession (or falls into one this year or next). Here's how O'Reilly could be a recession-proof stock.

All-weather performance

Selling car parts is not what you'd call a headline-grabbing business, but it plays a vital role in our everyday lives. Folks need their cars to get to work, pick up groceries, and take the kids to soccer practice. Having your car break down can grind a driver's life to a screeching halt until it can get repaired. Getting cars back up and running as quickly as possible drives demand for parts sellers like O'Reilly.

Shopper looking at motor oil.

Image source: Getty Images.

The thing to remember is that cars break down regardless of economic conditions. So O'Reilly does well when the economy is in expansion mode but can also stand its ground amid a recession. As a result, investors tend to view the stock as a defensive haven when times look tough, like in 2022.

For instance, in 2008, O'Reilly acquired CSK Auto Corporation and ended the year with revenue of $3.6 billion. During the recessionary period brought on by the financial crisis, O'Reilly's revenue increased 36% to $4.8 billion in 2009. Then in 2010, the company grew sales by 11% to $5.4 billion. Over the same time, while integrating its acquisition, O'Reilly doubled its earnings per share from $1.50 to $3.02.

A recent survey of economists shows an increase in their estimated recession probability over the next 12 months, from 30% in June to 47.5% in July. Despite the increased likelihood of a recession this year or next, O'Reilly stock has held up well. The stock is down a mere 2% this year, compared to a 16% drop in the S&P 500.

More of the same

In its second quarter earnings report, as inflation heated up in the U.S., O'Reilly announced full-year guidance for comparable-sales growth in a range of 3% to 5%, similar to the 4.8% it posted in the first quarter. Comparable-sales growth comes from established stores and does not count new stores ramping up. O'Reilly also said it had successfully increased prices to offset its inflated costs.

In its second quarter earnings report, the company also said that it had repurchased 2.2 million shares for $1.38 billion. An additional 400,000 shares were repurchased between the quarter's end and the earnings release date. O'Reilly also added 89 new stores during the quarter.

Remember that real GDP fell in the second quarter, and inflation remains high. If it turns out that the U.S. was in a recession during that time, O'Reilly's stellar second-quarter performance may showcase the recession-proof nature of its business. Recession-sensitive investors should have O'Reilly's stock on their radar.