Stocks extended gains and the Nasdaq trimmed losses on Wednesday as financial shares gained a day before the release of stress test results while energy shares rose in sync with oil prices' 4 percent jump.

Research In Motion gave one of the biggest lifts to the Nasdaq after JP Morgan upgraded the BlackBerry maker's stock to neutral from underweight.

The Dow Jones industrial average <.DJI> rose 51.85 points, or 0.62 percent, to 8,462.50. The Standard & Poor's 500 Index <.SPX> added 8.93 points, or 0.99 percent, to 912.73. The Nasdaq Composite Index <.IXIC> was off 2.89 points, or 0.16 percent, to 1,751.23.

(Reporting by Leah Schnurr; Editing by Jan Paschal)