Excitement about artificial intelligence (AI) has driven market gains this year, and investors have piled into companies developing or using the technology -- from chip designer Nvidia to electric vehicle (EV) giant Tesla. These players are among the top five favorites of retail investors this year, with those stocks seeing billions of dollars in net inflows. And performance has reflected this, with these two particular stocks advancing in the triple and double digits, respectively, this year.

Nvidia is the stock that saw the biggest net inflows from retail investors -- nearly $30 billion -- according to Vanda Research, and Tesla took the third spot with net inflows of more than $14 billion. But another asset proved more popular than the top EV stock, securing the position as retail investors' second-most-purchased security.

This asset just so happens to be a favorite of billionaire Warren Buffett, who holds it within his portfolio. The Oracle of Omaha, as he's often called, also recommends it as an ideal investment for nonprofessional investors, and even has instructed trustees to put most of his cash into it for the benefit of his wife upon his death. So this truly is a Buffett-endorsed investment. On top of this, buying this security could potentially make you a millionaire. Let's find out how.

Warren Buffett is seen at an event.

Image source: The Motley Fool.

Betting on a famous benchmark

So, what is this investment that Warren Buffett and retail investors love? It's the SPDR S&P 500 ETF Trust (SPY -1.05%), an exchange-traded fund that tracks the performance of the S&P 500. To do this, it mimics the composition of the famous benchmark, holding the same shares at the same weighting. This results in this ETF delivering the same performance as the index -- making it the perfect way to bet on the S&P 500.

SPY Chart

SPY data by YCharts

Why would you want to bet on the benchmark? Buffett offers us one answer: "American business has done wonderfully over time and will continue to do so," the investing giant wrote in his 2013 letter to shareholders. He went on to say, nonprofessional investors should "own a cross-section of businesses that in aggregate are bound to do well. A low-cost S&P 500 index fund will achieve this goal."

And a second reason to buy this ETF has to do with the S&P 500's performance over time -- this supports Buffett's comment, above. The benchmark has posted an average annual return of more than 10% since its debut as a 500-company index in the late 1950s. Of course, there's no guarantee this will continue, but considering the length of this track record, there's reason to be optimistic about index performance over the long run.

Owning this ETF also offers you exposure to the biggest themes of the moment -- such as AI right now -- because leading companies of the times make up the index. Meanwhile, the ETF and index, including 11 sectors, offer you diversification, too -- this limits the negative impact if one of these hot investment areas loses momentum. So the ETF Trust brings you the fantastic combination of growth potential and security.

Investing over time

Now let's consider how buying the SPDR S&P 500 ETF Trust might make you a millionaire. This involves the idea of picking up shares of the fund regularly over a period of years -- and by doing this, you'll benefit from the magic of compounding.

Here are the numbers behind this millionaire-maker strategy. Let's imagine the index continues with the average annual return of about 10%. If you initially buy $1,000 of SPDR S&P 500 ETF Trust shares and then invest $300 in the index every month for 35 years, your investment could reach $1 million. You would have contributed $127,000 -- and your returns would have topped $876,000. That's an enormous win for your portfolio.

Of course, you may not be able to invest that much per month or keep the investment going for such a long period of time. But even with a smaller investment over a shorter time period, you still could win by using this strategy because your returns may greatly surpass your contributions. The key is to invest regularly and over several years.

All of this means, as we head into the new investing year, that adding shares of this Buffett and retail investor favorite is a great idea -- it could progressively boost your portfolio and even eventually make you a millionaire.