As an auto parts retailer, O'Reilly (ORLY 0.37%) 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 sexy 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 be recession-proof. 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

Earlier in 2022, as inflation heated up in the U.S., O'Reilly stood by its full-year guidance for comparable-sales growth in a range of 5% to 7%, which is above 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 Q1 earnings report, the company also announced that it had repurchased 1.2 million shares for $775 million. An additional 200,000 shares were repurchased between the quarter's end and the earnings release. O'Reilly also added 55 new stores in the quarter.

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