With the S&P 500 seemingly hitting a new all-time high daily, investors are searching the market for the hottest industries and contributors to the rally. The biggest factor in the marketwide rally is the tech sector -- specifically big tech -- where the market caps have gotten so large that a few companies alone can move the entire market.

There are currently five companies with a market capitalization of over $1 trillion: Apple, Microsoft, Alphabet, Amazon, and Nvidia. And there are just 12 companies with a market cap of over half a trillion dollars, which are those five plus Meta Platforms, Berkshire Hathaway, Tesla, Eli Lilly, Taiwan Semiconductor, Broadcom, and Visa.

It could take a while, but I believe that within the next three to five years, Procter & Gamble (PG -0.78%) will become the first company with over 50 consecutive annual dividend raises -- known as a Dividend King -- to surpass $500 billion in market value. Here's why P&G has what it takes to reach this milestone.

A person looking inquisitively at a computer screen while sitting at a table and holding a pen close to their mouth.

Image source: Getty Images.

The frontrunners

There are currently 54 Dividend Kings, but only seven of them have a market cap of around $200 billion or more.

WMT Market Cap Chart

WMT Market Cap data by YCharts

Walmart is the leader with a $437 billion market value. It would need to gain just 14.4% to reach $500 billion. I like Walmart, but the rally since its last reported earnings has been largely unjustified. Walmart is dealing with a slew of challenges. And unlike its peer Target, which remains down over 47% from its all-time high, Walmart is down less than 5% from its all-time high.

Target has more of a consumer discretionary mix than Walmart, and it mismanaged its inventory and supply chain in recent times. However, the fact remains that Walmart is facing low growth. Its net income is virtually unchanged from 10 years ago, and its operating margin is relatively low as well.

WMT Revenue (TTM) Chart

WMT Revenue (TTM) data by YCharts

After reporting fiscal 2024 third-quarter results in November, Walmart stock initially sold off before falling even further, to around $150 a share. It's been a sizable bounce since then for no real reason. Walmart is still a solid long-term holding for its recession resilience and growing dividend. But the above market valuation with a price-to-earnings (P/E) ratio of about 27 leaves too much room for a sell-off.

The perfect Dividend King

P&G has to outperform Walmart by quite a bit to beat it to $500 billion in market value. But there are a few reasons it could pull this off.

PG Revenue (TTM) Chart

PG Revenue (TTM) data by YCharts

P&G is generating practically as much free cash flow (FCF) as net income. Revenue growth has been solid, and its margins have held up despite a challenging operating environment. P&G has several partners and deals through different sales channels, so it can sustain higher margins than a pure-play retailer. Despite clocking in at a whopping $348 billion market cap, P&G is a lean business.

P&G routinely generates far more sales than it needs to run the business -- hence the high margins and FCF. It passes that cash flow to shareholders through a growing dividend and buybacks.

While dividends won't help P&G grow its market cap, they provide an incentive to hold a stock through periods of volatility. Not only is P&G one of the longest-tenured Dividend Kings, but its dividend also yields 2.6%, which is quite a bit higher than Walmart's 1.4%.

As for the buybacks, P&G has reduced its outstanding share count by 13% over the past decade compared to 16.6% for Walmart. Both companies have done an excellent job boosting earnings per share through buybacks, which has helped make both companies a better value when organic growth is sluggish.

P&G also looks like a far better value than Walmart. P&G sports a P/E ratio of 24 and a price-to-FCF ratio of 25.1. By comparison, Walmart has a P/E ratio of 26.9 and a price-to-FCF ratio of 34.6.

Coincidentally, Coca-Cola has an almost identical valuation to P&G, with a P/E ratio of 23.9 and a price-to-FCF ratio of 25.4. The difference is that Coke would have to nearly double to reach $500 billion in market size. Coke is a worthy dividend stock with a solid 3.1% yield. But when it comes to a race among Dividend Kings, it's just too small and similar to P&G to compete at this time.

A quality company with room to run

It wouldn't surprise me if Walmart touched a $500 billion market cap before P&G on a whim of market exuberance. But in terms of which company will surpass that market cap and stay above the threshold, I think no Dividend King holds a candle to P&G.

P&G is, in many ways, a perfect business. There is almost nothing not to like about it. Despite improving fundamentals, the stock has gone practically nowhere over the last year and is down around 10% from its all-time high. That makes it stand out as a buying opportunity.

It may take three to five years, but it wouldn't surprise me one bit if P&G gains at least 43% to surpass $500 billion in market value -- all while rewarding its shareholders handsomely with predictable buybacks and a growing dividend.