Investors in 2022 have suffered through one of the worst starts to the year in the market's history. The S&P 500 index is currently down 18% year to date. While it's very difficult to predict short-term market movements, it's much easier to identify which companies are positioned to deliver compounding returns over many years.

Software stocks have been hit hard this year, but the lower stock prices are giving investors a great opportunity to scoop up the best of the best at lower valuations. Salesforce (CRM -0.57%) and Microsoft (MSFT -1.27%) generate consistent revenue growth through their software-as-a-service business strategies, and these leaders generate a high free cash flow margin, which adds to their long-term value to investors. Here's why now is the time to consider adding these stocks to your portfolio.

Salesforce: The leading customer relationship management platform

Salesforce has become an indispensable software provider for over 150,000 companies. It's the leading customer relationship management platform, serving a growing addressable market worth about $200 billion. The best part is that investors can buy shares at their cheapest valuation since the 2008 market crash. There are a few qualities about Salesforce that suggest the market is undervaluing the stock right now.

Salesforce's Customer 360 cloud-based platform frees companies from having to manage and install separate applications, and instead helps employees gain easier access to customer data across teams including sales, marketing, commerce, and more.

Over the four quarters ended in July, the company generated $5.7 billion of free cash flow on $29 billion of revenue. Both those numbers have roughly tripled in just the last five years. The company has consistently grown revenue at 20% or better annually for over a decade, and it's not done growing. In fact, management recently announced a share repurchase program, which is a vote of confidence in Salesforce's future, in addition to management's view that the shares offer tremendous value right now. 

CRM Free Cash Flow Chart

CRM Free Cash Flow data by YCharts

Despite the challenging economic environment, Salesforce expects revenue to grow 20% this year on a constant-currency basis. In the second quarter, it notched customer wins with the U.S. Department of Veteran Affairs, Workday, and Uber Technologies. Many companies are looking to consolidate services to save money in a weakening economy. Salesforce's recent growth and customer wins reflect a strong competitive position with a wide range of services it can offer customers.

The stock trades at a price-to-sales ratio of 5.2, which is close where it traded at the low point of the 2008 market crash. You don't want to miss this rare opportunity to buy this leading software company at this discounted level.

Microsoft: The cash-rich software giant

Microsoft's $65 billion in trailing-12-month free cash flow makes it a no-brainer software stock to hold for the long haul. The company finished the most recent quarter with over $100 billion in cash and short-term investments, though it is spending $68 billion of that in an all-cash transaction to acquire top video game producer Activision Blizzard. Microsoft has enough available money that it can pay all cash for that deal -- one of the biggest tech deals in history -- while still investing in its core business to drive long-term growth. A business that can afford all that is one worth investing in.

MSFT Free Cash Flow Chart

MSFT Free Cash Flow data by YCharts

Microsoft offers many essential software tools for individuals and businesses. With Office 365, Microsoft Teams, and enterprise cloud services with Microsoft Azure, no company is better positioned to help organizations increase efficiency and save money in this environment. That explains why Microsoft was able to maintain a solid 12% growth in revenue last quarter.

One of Microsoft's crown jewels is Azure, which is the No. 2 cloud services provider behind Amazon's Amazon Web Services. Microsoft management reported larger and longer commitments in cloud services last quarter. Azure posted revenue growth of 40% year over year. The company plans to build data centers in 10 new regions over the next year to support future growth. 

The stock's valuation is attractive at a price-to-earnings (P/E) ratio of 23 based on next year's earnings estimates. The growth potential is worth the premium to the S&P 500's P/E of 19.7. Microsoft's profitability and growing dividend payments should reward investors for many years to come.