Energy shares helped the Dow and S&P 500 end a three-day losing streak on Tuesday, even as investors worried rising fuel costs will undercut economic growth.

The Dow Jones industrial average <.DJI> gained 34.36 points, or 0.30 percent, to 11,671.81, according to the latest available figures. The Standard & Poor's 500 <.SPX> gained 4.72 points, or 0.37 percent, to 1,274.47. The Nasdaq Composite <.IXIC> gained 9.03 points, or 0.33 percent, to 2,716.83.

(Editing by Kenneth Barry)