Last year's tech sell-off led many of the world's most valuable companies to experience substantial stock declines as economic headwinds were followed by reduced consumer spending. Amazon (AMZN -1.65%) and Advanced Micro Devices (AMD 1.33%) stocks fell 49% and 55% throughout 2022, alongside revenue declines in their e-commerce and PC component businesses.

However, these companies' stocks have risen in 2023 as tech stocks have gradually returned to favor. Amazon shares have increased 14% and AMD's 17% year to date, with signs of the market recovering prompting an attractive time to invest in one of these tech giants. 

So, let's consider whether you're better off investing in AMD or Amazon stock. 

AMD: Resilient amid market declines

AMD made a name for itself among consumers as a strong rival to Nvidia and Intel, offering powerful PC components such as graphics processing units (GPUs) and central processing units (CPUs). The rise of people opting to build custom gaming PCs over the last decade has helped skyrocket AMD's business, with its revenue rising 264% to $23.6 billion and operating income up 180% to $1.26 billion since 2019.  

As a result, AMD's stock has soared 550% in the last five years, even considering last year's sell-off.

While the PC industry has catapulted AMD into a dominating position in tech, 2022's market declines meant the company had to pivot or fall -- and it did so gracefully. In fiscal 2022, AMD's client and gaming segments, primarily made up of earnings from consumer PC components, experienced revenue declines of 50% and 6% year over year.

However, its highest-earning segment in 2022 was data centers, which reported a revenue rise of 42%, earning $1.6 billion. Meanwhile, its embedded segment had revenue grow 1,800% to $1.3 billion.

Data center growth is mainly owed to the booming cloud computing industry, valued at $483 billion in 2022 and projected to grow at a compound annual growth rate of 14.1% through 2030. AMD's GPUs power data centers worldwide and are crucial to the market's growth. Additionally, AMD's embedded business has soared after acquiring tech company Xilinx last year. Xilinx specializes in producing programmable CPUs for industries such as artificial intelligence, aerospace and defense, space, and more. 

AMD suffered a tough 2022. However, its pivot to more lucrative parts of its business has proven its resilience and will likely keep the company on its current growth trajectory. 

Amazon: The leader of two high-growth industries

Macroeconomic declines were detrimental to Amazon's e-commerce business in 2022, with its North American and International segments reporting combined operating losses of $10.5 billion over the year. Despite the sharp declines, the e-commerce market continues to have a lucrative outlook, with Amazon's 37.8% market share in the U.S. likely to prove a major asset once economic headwinds subside. For reference, the second-largest market share is Walmart, with 6.3%. 

According to Grand View Research, the e-commerce market was valued at $9.09 trillion in 2019 and is projected to expand at a compound annual growth rate (CAGR) of 14.7% through 2027. Meanwhile, online sales comprised 19.7% of all worldwide retail sales in 2022, and are expected to hit 24% in 2026. As a result, Amazon makes a compelling long-term investment for when its e-commerce segments can return to profitability. 

The biggest reason to consider buying Amazon's stock is its dominating position in the cloud market with Amazon Web Services (AWS). The cloud service held a leading 34% market share in the industry in third-quarter 2022 and propped the company up amid a challenging previous year. AWS was responsible for 100% of Amazon's $12.2 billion in operating income in 2022, after a 28.7% year-over-year rise in revenue of $80 billion.

Amazon and AMD both have solid positions in tech and continue to have positive long-term outlooks, despite a grueling 2022. The decision on which stock is the better buy lies in their current stock prices. Amazon's forward price-to-earnings ratio currently sits at 63, while AMD's is a preferable 25, suggesting the semiconductor company's stock is a better value.

Additionally, AMD's free cash flow of $3.5 billion, compared to Amazon's negative $16.8 billion, shows it may be better equipped to overcome further economic downturns. As a result, AMD's stock is currently the better buy. However, keeping Amazon shares on your radar is also a good idea, so you can strike at the right time.