Though they play in different sandboxes after recent decisions altered their respective businesses, both HP (HPQ -0.61%) and IBM (IBM -1.06%) still have a lot in common. In addition to being signature members of the tech industry's "old guard," both HP and IBM have undergone drastic, and much-needed, transformations the past couple of years.

HP's decision to split off its software and services unit into Hewlett-Packard Enterprises to focus on its PC and printing solutions was a big one, to be sure. But IBM's transformation away from chips, hardware, and related old-school technologies has been just as impactful for shareholders. So, which is the better buy, HP or IBM?

Image source: HP.

The case for HP

Most tech investors are aware of the dire condition of the world's PC market. According to technology research company Gartner, worldwide PC shipments declined again in the first quarter, to 64.8 million units -- the lowest number since 2007. About the only good news following the dismal report is that HP's 11.41 million PC units moved during the first quarter was a slight improvement in market share, to 17.6%.

Last quarter's 10% decline in revenue from the personal systems segment, to $6.99 billion, could have been much worse if not for HP's relatively strong commercial sales, which dropped a "mere" 7%. Revenue from HP's consumer segment fell 16% in fiscal 2016's second quarter. The question is, how does HP stop the bleeding? By positioning itself as the innovation leader -- case in point, HP's new Spectre laptop, billed as the "world's thinnest."

HP also has plans to kick-start its printing business, which really took a beating in Q2, dropping 16%, to $4.64 billion. Once again, consumer sales was the culprit, with printer revenue down a whopping 18%. For HP, a continued emphasis on enterprise sales and its foray into the 3D printing market could be the unit's saving grace.

3D printing generated $5.17 billion in revenue last year, and HP's latest "production-ready 3D printing system," along with its bevy of desktop units, should give it a leg up in what are still the early stages of the budding industry.

Image source: IBM.

The case for IBM

IBM's transformation continues to dictate how CEO Ginni Rometty and team are looking to the future. IBM stock has quietly risen 9% this year (HP is up 4.5%), but that has hardly quieted its critics as total revenue continues to decline. However, to determine which stock is the better buy, investors need to recognize Rometty's "strategic imperatives" are the future of IBM.

IBM reported a 4.6% drop in revenue in Q1, to $18.68 billion, and will likely mark further declines when it shares Q2 results July 18. The naysayers also lament IBM's nearly 21% drop in hardware and related sales last quarter, but those are legacy businesses. IBM's success will be determined by its performance in the cloud, cognitive computing or artificial intelligence (AI), and Internet of Things (IoT) analytics.

Toward that end, IBM's Q1 wasn't quite hitting on all cylinders, but there was a lot to like. Combined, strategic imperative sales are now at an annual run rate of $29.8 billion, equal to 37% of total revenue. Thanks in large part to the opportunity IBM's cognitive computing solutions represent, analysts think strategic imperatives will account for over 50% of IBM's revenue by this time next year -- well ahead of Rometty's own target of 40% by 2018.

HP and IBM share another important characteristic: Each is near the top of the dividend-paying heap in the tech industry. HP's dividend yield is 4%, while IBM is close behind, offering shareholders 3.75%. But when it comes to which stock offers the best opportunity going forward, IBM has the upper hand, for a couple of reasons.

First, HP is overly reliant on PCs and printers, both dying industries in their current form. HP's innovative tablets and 3D printers should give shareholders some hope, but there remain too many uncertainties and obstacles to overcome. Second, IBM's migration into cloud, AI, and IoT analytics sales offers limitless upside, as each category is further along the growth curve than HP's tablets or 3D printers. Investor patience is necessary in either case, but IBM will reward that patience before HP manages to.