Technology stocks have been bruised and battered in 2022 amid the broader stock market sell-off and factors such as surging inflation, higher interest rates, and weak consumer spending. The tech-laden Nasdaq-100 Technology Sector index has shed more than 32% of its value so far this year.

But investors shouldn't forget that technology stocks have been winners, in the long run, thanks to the presence of disruptive and innovative companies in this sector. This is evident from the Nasdaq-100's impressive gains over the past decade as compared to the S&P 500 index.

^SPX Chart

^SPX data by YCharts

That's why investors looking to add top growth stocks for the long run to their portfolios have a great opportunity to buy some top technology companies on the cheap following their slide in 2022. Here are two tech stocks that could help set you up for terrific long-term gains.

1. Taiwan Semiconductor Manufacturing

Taiwan Semiconductor Manufacturing (TSM -0.47%), popularly known as TSMC, is a Taiwanese foundry that makes chips that are used across a wide range of industries, including smartphones, data centers, the Internet of Things (IoT), and the automotive market.

The booming semiconductor demand thanks to the growth of the above-mentioned markets has been driving terrific growth at TSMC. The company's revenue in the first quarter of 2022 had shot up 36% year over year to $17.6 billion, driven by the demand for chips that are used in high-performance computing (HPC), smartphones, and automotive. The company's earnings had jumped 45% year over year to $1.40 per share during the quarter.

What's more, TSMC's June revenue report indicates that the demand for its chip manufacturing services remains healthy. The company's revenue during the month was up 18.5% year over year. Its top line has increased nearly 40% in the first half of the year. TSMC management is confident of sustaining its impressive growth for a long time to come.

In its 2021 shareholder letter, TSMC management remarked that the company is "entering a period of higher structural growth, as the multi-year megatrends of 5G and High-Performance Computing (HPC)-related applications are expected to fuel massive demand for computation power, which expand the use of leading-edge technologies."

More importantly, TSMC is working to enhance its manufacturing capacity to take advantage of the secular growth opportunity and is aggressively increasing its capital investments. TSMC is the top semiconductor foundry by market share, occupying 53.6% of this market as per a third-party report. It enjoys a big lead over second-ranked Samsung which has a market share of just 16.3%. The aggressive capital spending is the reason why TSMC's share of the foundry market is expected to go up to 56% this year, according to market research firm TrendForce.

And that's a good thing as the semiconductor foundry market is expected to add $60 billion in annual revenue over the next six years. TSMC's robust market share puts it in a solid position to tap into that incremental growth. Even better, TSMC could keep growing at a nice pace well beyond the next five years as the semiconductor industry is expected to generate a trillion dollars in annual revenue by 2030 as compared to $600 billion last year.

Throw in a nice dividend yield of 2.4%, a low payout ratio of 30%, and low earnings multiple of 19, investors have more reasons to buy this semiconductor stock that has generated annual returns of nearly 23% over the last decade, assuming the dividends were reinvested.

2. Palo Alto Networks

Palo Alto Networks (PANW 0.04%) is one of the leading players in the cybersecurity market with a market share of almost 19%. This puts the company in a prime position to take advantage of a massive end-market opportunity.

Cybersecurity spending is expected to hit $1 trillion by 2035 as compared to last year's estimated outlay of $145 billion. Not surprisingly, analysts expect Palo Alto's earnings to increase at a compound annual rate of 27% for the next five years -- a pace that it could easily maintain beyond that thanks to its market share and the expansion in spending.

More importantly, Palo Alto is taking steps to boost its share of the booming cybersecurity market. That's evident from the fact that it released 29 new products in fiscal 2021 as compared to 13 new products in fiscal 2019. The company's moves are bearing fruit as customers are spending more money on Palo Alto's offerings.

Palo Alto forecasts rapid growth in the coming years. The company expects revenue to increase at an annual rate of 23% through fiscal 2024. Palo Alto also forecasts an expansion of 50 basis points to 100 basis points in its adjusted operating margin through fiscal 2024, while the adjusted free cash flow margin is expected to grow between 100 and 150 basis points over the same period.

However, investors shouldn't forget that Palo Alto is an expensive stock that's trading at nearly 10 times sales. That's quite rich when compared to the S&P 500's sales multiple of 2.49. But then, Palo Alto's valuation seems reasonable when compared to its cybersecurity peers.

PANW PS Ratio Chart

PANW PS Ratio data by YCharts

It is also worth noting that Palo Alto has been growing at a faster pace than its rivals for a long time.

PANW Revenue (TTM) Chart

PANW Revenue (TTM) data by YCharts

All this indicates that Palo Alto Networks is a best-of-breed cybersecurity play that could continue outpacing its peers' growth thanks to a combination of its healthy market share and the opportunity in the market it operates in and set up investors' portfolios for robust long-term gains.