Artificial intelligence (AI) is transforming the global economy, providing investors one of the best investment opportunities in decades. Like any technology revolution, there will be winners and losers. But with spending on AI growing rapidly, simply sticking with profitable, industry-leading companies can help you beat the average return of the stock market.

For investors who want to profit off the AI boom while sleeping well at night, here are two stocks with a long history of delivering market-beating returns to add to your long-term investment portfolio.

A digital brain with the letters AI written on it, hovering over a computer circuit.

Image source: Getty Images.

1. Broadcom

Every quarter, big tech companies pour major investment into AI and data centers. This is fueling growth for leading semiconductor companies like Broadcom (AVGO 3.36%), which supplies chips and networking components for the data center market.

Broadcom has been a leader in the semiconductor industry for many years, including supplying components for Apple's iPhone. It offers a broad portfolio of semiconductor, networking, and software products for telecommunications, home connectivity, smartphones, and other markets. Management allocates capital to markets where it can generate high margins, and this is a key reason why the stock has returned 2,460% over the last 10 years.

Broadcom's recent earnings reports show it is positioned to capitalize on growing demand for AI infrastructure. Its data center business is booming. In the last quarter, sales of Broadcom's AI chips for data centers grew 46% year over year. The stock has rocketed nearly 775% in just the last five years.

AI companies are investing in more cost-effective chips for specific tasks where Nvidia's general-purpose graphics processing units (GPUs) are overkill and too expensive. Broadcom has worked with OpenAI on designing its first chip, and this could be a big opportunity.

Broadcom sees recent growth in its AI semiconductors carrying over to next year. Analysts are expecting Broadcom's revenue to grow at an annualized rate of 20% through 2027.

This is a highly profitable business. It generated over $22 billion in free cash flow on $57 billion of revenue over the last year. Analysts expect free cash flow to reach $64 billion over the next five years. The shares should continue to perform well as Broadcom meets the growing demand for high-performance products for the data center market.

2. ServiceNow

Businesses are investing in AI software to automate workflows, and this is benefiting ServiceNow (NOW 5.06%). It has about 8,400 customers worldwide, serving over 85% of the Fortune 500. The company's subscription-based business model makes it a solid investment to keep in your long-term portfolio.

Like Broadcom, ServiceNow has a long record of delivering stellar returns. The company's revenue has grown at a 32% annualized rate over the last 10 years, which fueled shareholder returns of 1,100%, and the stock has nearly doubled in the last five years.

Businesses love ServiceNow because it offers AI-driven software solutions for streamlining employee workflows at a relatively affordable price for large enterprises. In Q2, the company beat its guidance, with revenue up 22% year over year, maintaining its history of delivering very consistent 20% or better top-line growth.

Annual contract value for ServiceNow's Now Assist platform surpassed expectations, with its AI Pro Plus deal count up 50% over the previous quarter. It closed a deal worth over $20 million, marking its largest to date, indicating the AI opportunity is massive.

The adoption of Now Assist is exceeding management's expectations. Its large deal sizes are validation of ServiceNow's competitive advantage in the digital workflow market. Management sees a massive opportunity in the $100 billion customer relationship management market, where it secured deals with ExxonMobil, Merck, and the state of California in the quarter.

The recurring revenue from subscriptions helps the business generate consistent free cash flow that fuels shareholder returns. Analysts expect the company's free cash flow to grow at an annualized rate of 21% to reach $9 over the next five years, which should fuel the stock higher.