Dec 21 (Reuters) - Wall Street's main stock indexes closed higher on Wednesday with help from upbeat Nike and FedEx quarterly earnings, as well as improving consumer confidence and easing inflation expectations from investors.

Nike Inc shares rallied sharply after beating profit expectations for its second quarter on strong holiday demand from North American shoppers, while FedEx also gained and shares in cruise operator Carnival Corp jumped after posting a smaller-than-expected quarterly loss.

FedEx Corp, which sparked a market selloff in September after pulling financial forecasts, provided financial guidance and announced plans for $1 billion cost cuts.

U.S. consumer confidence rose to an eight-month high in December as inflation retreated and the labor market remained strong while 12-month inflation expectations fell to 6.7%, the lowest since September 2021.

"We're seeing a broad rally. It's been helped by upbeat corporate commentary and an improvement in consumer confidence," said Angelo Kourkafas, investment strategist at Edward Jones in St. Louis referring to Nike and FedEx.

According to preliminary data, the S&P 500 gained 56.44 points, or 1.48%, to end at 3,878.68 points, while the Nasdaq Composite gained 159.65 points, or 1.51%, to 10,706.76. The Dow Jones Industrial Average rose 522.07 points, or 1.59%, to 33,371.81.

Still, Wednesday's data also showed that U.S. existing home sales slumped 7.7% to a 2-1/2-year low in November as the housing market was hurt by higher mortgage rates. But the data may be fuelling investor hope that the Fed could ease up on its tightening policy.

"At the macro level you have economic weakness but at the micro level you have companies that are resilient and delivering positive expectations from an earnings perspective," said Brian Price, head of investment management for Commonwealth Financial Network in Waltham, Mass. "That combination is going to be positive."

Fears of a recession following the U.S. central bank's prolonged interest rate hikes have weighed heavily on equities and these fears have put the S&P on track for its biggest annual decline since 2008 and a decline for December.

"There's still a lot of uncertainty and we're likely to see a lot of volatility early in the year as we could be in a mild recessionary environment," said Edward Jones' Kourkafas but he believes the market has already priced in a weaker economy.

"We still have some headwinds ahead but maybe we don't have to price in a recession twice. So far what we've seen this year has already priced in a mild recession."

AMC Entertainment Holdings Inc was up 3.6% after the cinema-chain operator said it suspended talks to acquire certain assets of bankrupt Cineworld Group. (Reporting by Sinéad Carew in New York, Shubham Batra, Amruta Khandekar, Ankika Biswas and Johann M Cherian in Bengaluru; Editing by Shounak Dasgupta, Maju Samuel and Aurora Ellis)