Soaring inflation and rising interest rates have weighed on the stock market this year. In fact, the S&P 500 had its worst first half since 1970, falling more than 20% between January and June. But that hasn't stopped the spread of stock-split mania.

With little else to get excited about, some investors have enthusiastically embraced the recent wave of stock splits, and there is some logic to that. Forward stock splits are typically only necessary after significant share price appreciation, meaning they tend to indicate that a company is doing something right.

With that in mind, these two companies recently completed stock splits, and both stocks look like smart long-term investments. 

1. Amazon

Rising costs have put pressure on Amazon (AMZN -1.39%) this year. The company posted a generally accepted accounting principles (GAAP) loss in each of the last two quarters, marking the first time it failed to achieve quarterly profits since 2015. That has some investors feeling anxious, but inflation is a temporary headwind, and Amazon is well positioned to accelerate profitability down the road.

Of course, most consumers associate Amazon with e-commerce -- its marketplace powered 41% of online retail sales in the U.S. last year, and its expansive logistic infrastructure helps create a great experience for buyers and sellers, supercharging the network effects that power its business. But Amazon is also the undisputed leader in cloud computing, and that should make the company more profitable over time.

In the first quarter, Amazon Web Services (AWS) captured a 33% market share in cloud services, more than the next two vendors combined, and the company is unlikely to lose its edge anytime soon. Research firm Gartner recently recognized AWS as the industry leader, citing its unrivaled capacity for innovation and its broad portfolio as key advantages.

That's particularly noteworthy because cloud computing is much more profitable than retail. Over the past few years, AWS has consistently posted operating margins of around 30%, but the operating margin on the remainder of Amazon's business rarely tops 5%. Better yet, the cloud computing market is expected to grow at nearly 16% per year to reach $1.6 trillion by 2030, according to Grand View Research.

That trend should keep AWS in growth mode for years, and as it becomes a larger percentage of Amazon's top line, the company should become increasingly profitable. But Amazon is also gaining market share in digital advertising, another high-margin industry that should turbocharge profitability in the long run.

On that note, shares currently trade at 2.9 times sales, a discount to its five-year average of 3.8 times sales. That's why this stock-split stock is a smart buy right now.

2. Shopify

Shopify (SHOP -2.09%) grew at an explosive pace during the pandemic, but the company is now battling the same headwinds as Amazon. Consumers have responded to persistent inflation by cutting back on discretionary online purchases, choosing instead to prioritize essentials like food and fuel. As a result, Shopify saw sales growth slow to 16% in the second quarter, down from 57% in the prior year, and it posted a GAAP loss of $0.95 per diluted share, down from a profit of $0.69 per diluted share.

Those disappointing results have some investors feeling bearish, but Shopify is well positioned to weather the storm and emerge stronger on the other side. Its platform allows merchants to manage orders and sales across physical and digital storefronts. That includes online marketplaces like Amazon and social media like TikTok, but it also includes direct-to-consumer (DTC) websites.

That gives Shopify an edge over marketplace operators. DTC business models are gaining momentum because they offer brands more control over the buyer experience, increasing the likelihood of lasting customer relationships. Shopify supplements its software with a number of adjacent services, including payment processing, discounted shipping, and financing. Those tools democratize commerce for merchants, and they have fueled strong demand. In fact, Shopify is the market leader in e-commerce software, and its platform powered 10.3% of online retail sales in the U.S. last year, second only to Amazon.

Turning to the future, Shopify has set in motion a growth strategy that should significantly strengthen its position in the commerce market. One facet of that strategy is the Shopify Fulfillment Network (SFN), a system of warehouses augmented with predictive software and mobile robots that will ultimately allow sellers to offer two-day delivery to buyers across the U.S.

Shopify is also working to grow upmarket with Shopify Plus, its software platform for larger businesses. Plus now features business-to-business (B2B) commerce tools, meaning merchants can sell B2B and D2C from the same online store. That opens the door to a potentially massive revenue stream. B2B e-commerce sales are expected to grow at nearly 20% per year to reach $33 trillion by 2030, according to Grand View Research.

Additionally, business-to-consumer e-commerce sales will total $5.5 trillion this year, putting Shopify in front of a tremendous market opportunity. And with shares trading at 9.1 times sales -- near a five-year low -- this growth stock is a screaming buy.