Stocks gained on Wednesday ahead of a key announcement by the Federal Reserve, led by technology and homebuilding shares after positive earnings reports.

The three major indexes all rose more than 1 percent, rebounding from a steep sell-off on Tuesday that had sent the broader S&P index down 1.27 percent, its steepest decline in five weeks.

Positive outlooks from Applied Materials , the world's largest producer of chip-making gear, and luxury homebuilder Toll Brothers Inc drove gains in the technology and homebuilder sectors.

Investors had been more cautious earlier in the day, awaiting results from a Federal Reserve meeting that could shed light on the state of the economy.

The Fed's monetary policy committee, which wraps up its two-day meeting Wednesday afternoon, is expected to leave the U.S. central bank's key target interest rate unchanged. But investors will parse the Fed's policy statement for any changes in its outlook or its program to buy Treasury bonds.

The market has tremendous amount of upside momentum, and declines seem to be eventually leading to higher prices. ... It shows that people are generally turning more optimistic, said Bruce Bittles, chief investment strategist at Robert W. Baird & Co. in Nashville, Tennessee.

The Fed's meeting is closely eyed but I don't expect them to say anything that is very far away from the neutral stance.

The Dow Jones industrial average <.DJI> was up 128.25 points, or 1.39 percent, at 9,369.70. The Standard & Poor's 500 Index <.SPX> was up 12.99 points, or 1.31 percent, at 1,007.34. The Nasdaq Composite Index <.IXIC> was up 33.16 points, or 1.68 percent, at 2,002.89.

The S&P is now up 49 percent from its closing-low set on March 9.

Shares of Applied Materials rose 4.9 percent to $13.87 after Morgan Stanley raised its price target. Applied Materials reported its quarterly results after the bell on Tuesday and said it would at least break even this year thanks to new orders and deep cost cuts.

Toll Brothers shares advanced 13.6 percent to $23.26 after the luxury homebuilder said its net signed contracts rose in the third quarter, the first increase in four years. Toll, which said preliminary results show revenue for its third quarter ended July 31 fell 42 percent, also said buyers appear more confident and less concerned about risk.

An index of homebuilder shares gained 5 percent <.DJUSHB>.

Adding to the market's positive tone, the U.S. government and Swiss bank UBS AG initialed agreements to settle their tax evasion dispute, ending weeks of tough negotiations between the two sides. The U.S.-listed shares of UBS rose 2 percent to $15.00.

JPMorgan Chase advanced by 2.7 percent to $42.34, adding to a rebound in financial stocks, which had led Tuesday's sell-off. The S&P financial sector index <.GSPF> was up 2.51 percent.

Shares of Macy's Inc rose 3 percent to $15.94, after the department store operator posted better-than-expected earnings and raising its outlook.

Also on Wednesday, the Commerce Department said the U.S. trade deficit widened less than forecast in June on gains in exports, which were spurred by a pick-up in global demand. The gap increased 4 percent to $27 billion from $26 billion in May.

(Editing by Leslie Adler)