U.S. stocks rose on Tuesday, led by commodity-related stocks, as speculation Greece would get help from the European Union to cut the country's deficit weakened the U.S. dollar, lifting prices of oil and basic materials.

Earnings results and upgrades of big names, including Coca Cola Co and Caterpillar Inc , gave further support to the advance, though indexes trimmed gains earlier in the session of more than 1 percent.

Caterpillar shares jumped 4.1 percent to $52.87, making it the biggest gainer on the blue-chip index, while Coke added 3.2 percent to $54.33.

Speculation Greece could get help from the EU underpinned the rise in stocks, even after two European Central Bank policymakers reiterated that Greece must get its own house in order.

Concerns over rising debt in some euro zone countries has sapped confidence from equity markets of late.

There's hope that something will be resolved (in Greece), said Richard Sichel, chief investment officer of Philadelphia Trust Co.

Investors are willing to put that aside and look at earnings and the somewhat more attractive valuations at the moment.

The Dow Jones industrial average <.DJI> gained 77.09 points, or 0.78 percent, to 9,985.48. The Standard & Poor's 500 Index <.SPX> rose 5.09 points, or 0.48 percent, to 1,061.83. The Nasdaq Composite Index <.IXIC> added 9.27 points, or 0.44 percent, to 2,135.32.

Morgan Stanley raised its rating on the industrial sector to attractive from in-line, saying those companies' share prices should catch up to an improving business environment. Rockwell Automation Inc rose 1.9 percent to $48.61 and Ingersoll-Rand Inc added 2.3 percent to $33.63, adding to the Caterpillar boost to the sector.

Coke reported a quarterly profit in line with analysts' estimates as strong volume in China, India and Brazil offset a decline in North America, while overseas sales helped lift McDonald's January same-store sales.

McDonald's shares added 0.5 percent to $63.21.

The euro was having its best day against the U.S. dollar in nearly a month, and a weaker greenback boosted commodity prices and resource shares.

Oil futures popped up 1.1 percent to $72.66 per barrel, and the S&P energy sector <.GSPE> gained 1.4 percent.

U.S. Steel Corp added 3.4 percent to $45.55.

Limiting gains on Nasdaq, shares of Electronic Arts Inc fell 9.9 percent to $15.76 after the company warned fiscal 2011 earnings would miss expectations.

(Editing by Padraic Cassidy)