The earnings beat from PepsiCo - the first big company to release third-quarter results - could be an exception ahead of gloomy expectations for Q3 earnings overall, amid high inflation and rising interest rates.

PepsiCo also lifted its annual forecasts for revenue and profit, while signaling resilient consumer demand.

Its domination of the carbonated drinks market with Coca-Cola has helped it raise prices with little resistance from customers, while its snacks business is benefiting from a shift to eating more at home than at restaurants to save money.

The price hikes from PepsiCo helped revenue rise across all segments, with average prices for its products up 17% for the quarter.

Despite Wednesday's rally, shares of PepsiCo were still down about 3% year-to-date as of Wednesday morning.