Investors didn't get big trading signals from economic data. The Institute for Supply Management reported that U.S. manufacturing picked up in May but noted that companies faced labor and raw materials shortages.

The Dow rose a modest one tenth of a percent while the S&P 500 and Nasdaq finished just below the breakeven line.

DataTrek Research Co-Founder Nick Colas says investors are looking ahead and bracing for Friday's jobs report.

"There's a big question mark around the Friday jobs report in trying to understand it. Is it going to be weak like the last month was and kind of reassure us that rates are going to stay low? Or is it going to come storming back and the 10-year (Treasury) goes to 1.7 or 1.8% and stocks come under some pressure? So I think we'll be in a holding pattern for a couple of days."

Optimism over the U.S. outlook for fuel demand this summer drove oil prices higher on Tuesday. And that in turn pumped up shares of big oil companies like Chevron and Conoco Phillips. Exxon Mobil rose more than 3%, making it the S&P's biggest gainer.

Abbot Laboratories, on the other hand, was the biggest decliner on the S&P, dropping 9%. The drug maker cut its full year profit forecast, dragging down the healthcare sector. It projects revenue from its COVID-19 diagnostic tests will fall sharply as more Americans get inoculated.

"Meme stocks" extended their torrid rally from the previous week. AMC Entertainment shares shot up nearly 23% after the theater chain said it sold $230 million of its stock.