Maybe you checked out this article looking for a dividend stock that can perform well regardless of stock market conditions. Or perhaps macroeconomic conditions are your greater concern. Either way, you're in luck. I believe that Advance Auto Parts (AAP 3.41%) is a safe bet in both cases.

Picking this car-parts retailer as a safe dividend investment isn't without concerns -- there's a counterargument I plan to address. But here's why this company could merit a spot in your portfolio.

The Advance Auto Parts investment thesis

Advance has over 4,700 store locations, selling car parts and accessories primarily to do-it-yourself (DIY) customers. However, it also has nearly 2,000 additional locations under its Carquest, Worldpac, and Autopart International brands, all of which primarily serve professional installers.

Advance may already seem like a massive operation, but it's far behind competitors AutoZone and O'Reilly Auto Parts, which have nearly 6,200 and 5,900 U.S. locations, respectively. This suggests Advance can get bigger. And indeed, management is investing money in opening new stores.

As Advance opens new stores -- it opened 78 in the first half of 2022 -- it can grow its revenue. This is the first pillar of an Advance Auto Parts investment thesis

The second pillar is just as important: As Advance expands, it can build on its already strong operating-income profit margin of 7.6% by leveraging its existing infrastructure. Moreover, the company is improving profitability by using its data to power decisions on when to offer discounts and when to refrain. 

Speaking of profitability, Advance averaged $630 million in annual free cash flow (FCF) from 2017 through 2021, inside its target FCF guidance going forward. For 2022, it expects to generate at least $700 million in FCF. And with a market capitalization of just $10 billion, this forward price-to-FCF valuation of about 14 is cheaper than a lot of stocks out there.

Finally, Advance's management is generously giving back to shareholders. Both AutoZone and O'Reilly have beaten the market over the past decade, in large part because they've repurchased greater than 40% of their shares outstanding. Advance has only recently begun to emulate its peers in this regard, spending nearly $900 million in 2021 alone buying back stock.

AAP Average Diluted Shares Outstanding (Quarterly) Chart

AAP Average Diluted Shares Outstanding (Quarterly) data by YCharts

Advance is also repurchasing shares while paying out a high-yield dividend, whereas AutoZone and O'Reilly don't. This can add to Advance shareholders' long-term gains as well.

AAP Dividend Yield Chart

AAP Dividend Yield data by YCharts

The bear argument could be a sneaky bull case

Some argue that auto-parts retailers like Advance Auto Parts serve a dying market. As drivers shift to electric vehicles (EVs), increasingly fewer people will perform DIY maintenance. Accordingly, Advance Auto Parts will fade from relevance long term.

This bear argument is certainly possible. But let's temper that doomsday outlook with some important counterpoints. First, even if DIY maintenance dies out, it's unlikely that independent professional mechanics will become obsolete. I doubt the future is dealership-owned auto shops only -- independent shops can still perform maintenance on EVs. Therefore, Advance will still have a customer base, given its large footprint of stores that caters to pros.

Moreover, the most optimistic forecasts place EV sales at only around 50% of total vehicle sales by 2030. That's still a lot of gas-powered cars being sold this decade. And the aging cars on the road will still mostly be powered by gas. In other words, the shift to EVs will be gradual at best. And aging vehicles will be in greater need of repairs with supplies from Advance and others.

If the end of gas-powered cars actually does become more visible on the horizon, Advance's management could adjust accordingly. Consider Occidental Petroleum -- a Warren Buffett favorite -- which is being disincentivized from reinvesting in its core business because of U.S. energy policy. Therefore, it's spending less on its business and giving more back to shareholders. The same could theoretically happen with Advance down the road in a worst-case scenario.

The safe-bet takeaway

If the stock market continues to stumble, Advance Auto Parts likely has limited downside, considering that its revenue, FCF, and dividend yield sit near record highs. 

And if the economy enters a recession, Advance is still well-positioned. According to management, about 60% of the products it sells are to DIY customers, and most sales are for essential purchases like routine oil changes. Consumers will keep spending on these categories even during tough times.

Long term, Advance still has a sizable runway to generate revenue and profits, as well as return money to shareholders. Therefore, I believe Advance stock is a safe bet in a variety of possible scenarios.