Over the past decade, the rise of smartphones and tablets has disrupted the market for traditional PCs. Longer-lasting hardware has also extended upgrade cycles, and PC makers saw their sales slow to a trickle.

Between 2007 and 2017 annual worldwide PC shipments fell from 271.2 million units to 262.5 million units according to research firm Gartner. Annual shipments have also fallen for six straight years, causing many investors to shun the stocks of PC makers.

Image source: Getty Images.

But if we look closer at Gartner's market share growth figures for 2017, we'll notice that some PC makers are faring much better than others.

Company

2017 Shipments

Year-Over-Year Growth

Total Market Share

HP

55.2 million

4.6%

21%

Lenovo

54.7 million

(2.2%)

20.8%

Dell

39.9 million

1.1%

15.2%

Apple

19.3 million

4.1%

7.4%

Asus

18.0 million

(12.3%)

6.8%

Acer Group

17.1 million

(6.5%)

6.5%

Others

58.4 million

(9.7%)

22.3%

Source: Gartner.

HP (NYSE:HPQ), Dell, and Apple (NASDAQ:AAPL) are clearly gaining ground at the expense of their rivals. HP, which reclaimed its title as the world's top PC maker from Lenovo last year, is experiencing robust demand for its new high-end ultrabooks and convertible devices, especially in North America.

Dell, which is struggling against HP in the US market, offset that softness with overseas growth. Meanwhile, Apple continues to rule the non-Windows PC market with its premium Mac products.

Today I'll highlight the top three stocks to buy in the PC market, and one related stock which investors should avoid.

Top stock to buy: HP

After splitting with Hewlett-Packard Enterprise in late 2015, HP became a more streamlined company with just two businesses -- PCs and printers. Prior to the split, HP mostly focused on budget devices.

But after the split, HP chased Apple into the premium market with well-received devices like the Spectre, and followed Microsoft's Surface with new 2-in-1 devices. It also launched new high-end gaming PCs and more secure systems for enterprise customers.

HP's Spectre x2. Image source: HP.

All those moves lifted HP's total PC shipments 6% annually during the fourth quarter, boosting the business' revenues by 13% to $9.1 billion. That marked an acceleration from its 12% growth in the third quarter and 10% growth in the second quarter. HP's PC operating margin remains under pressure due to cyclically high component costs (especially flash memory), but those pressures should wane over the next two years.

Meanwhile, HP's printing business also remains healthy thanks to strong sales of its consumer printers and printing supplies. HP is also expanding that business by expanding into new markets like mobile printers and industrial 3D printers and acquiring Samsung's printing unit, which will boost its market share in multifunction A3 printers. Wall Street expects HP's revenue and earnings to respectively rise 4% and 10% for the full year, and the stock still trades at a reasonable 12 times forward earnings.

Top stock to buy: Apple

Apple generates most of its revenue from the iPhone, but Mac revenues still accounted for 8% of its top line last quarter. Its Mac shipments and revenue both fell 5% annually during the quarter, but that was partly due to the lack of a new MacBook -- Apple instead launched its new iMac Pro in mid-December, closer to the end of the first quarter.

The iMac Pro. Image source: Apple.

But during the conference call, Apple CFO Luca Maestri noted that 60% of its Mac sales were "first time buyers and switchers" from Windows PCs, with a 90% conversion rate in China. Maestri also noted that Mac sales in emerging markets grew 13% annually with "all-time records" in Latin America, India, Turkey, Central America, and Europe.

The Mac, along with the iPhone and iPad, remain Apple's three pillars of growth as it gradually expands its software services business, which posted 18% annual sales growth last quarter and accounted for 10% of its top line.

Looking ahead, analysts expect Apple's revenue and earnings to respectively rise 18% and 25% this year -- solid growth numbers for a stock that trades at just 13 times forward earnings.

One stock to avoid: Intel

Since chipmaker Intel's (NASDAQ:INTC) x86 CPUs power the majority of PCs worldwide, it seems like an obvious play on rebounding PC sales. The company's 4% year-over-year sales growth and 37% jump in non-GAAP earnings last quarter -- which both beat analyst estimates -- also seem healthy.

Unfortunately, Intel's long-term growth is overshadowed by some serious security concerns. The recent Spectre and Meltdown flaws, which expose all modern Intel CPUs to hardware-level hacks, caused many companies to question their safety. Intel's "patch" then caused so many issues that Microsoft disabled the update, warning that it could "cause data loss or corruption".

Intel CEO Brian Krzanich also reportedly sold half his stock after being informed about the flaws but before making them public. The Wall Street Journal then claimed that Intel informed Chinese tech companies about the chip flaws before investors, the US government, or the public.

All this controversy leaves Intel vulnerable to its main rival, AMD (NASDAQ:AMD), which recently claimed that its new Zen 2 architecture would be fully protected from Spectre and Meltdown. AMD previously stated that its current-gen chips weren't vulnerable to Meltdown, and were only vulnerable to certain versions of Spectre.

Analysts expect Intel to post just 3% sales growth and 2% earnings growth this year, but those estimates could still be too high if AMD gains ground.

The key takeaways

The PC market is a tough one to thrive in, but HP and Apple are gaining ground at the expense of their rivals. However, investors should be mindful of laggards like Lenovo, which is weighed down by its weak mobile business, and seemingly solid suppliers like Intel, which faces tough questions about its management decisions and competitive threats.

10 stocks we like better than Apple
When investing geniuses David and Tom Gardner have a stock tip, it can pay to listen. After all, the newsletter they have run for over a decade, Motley Fool Stock Advisor, has tripled the market.*

David and Tom just revealed what they believe are the 10 best stocks for investors to buy right now... and Apple wasn't one of them! That's right -- they think these 10 stocks are even better buys.

Click here to learn about these picks!

*Stock Advisor returns as of January 2, 2018

Teresa Kersten is an employee of LinkedIn and is a member of The Motley Fool's board of directors. LinkedIn is owned by Microsoft. Leo Sun owns shares of HP. The Motley Fool owns shares of and recommends Apple. The Motley Fool has the following options: long January 2020 $150 calls on Apple and short January 2020 $155 calls on Apple. The Motley Fool recommends Gartner and Intel. The Motley Fool has a disclosure policy.