(Reuters) - U.S. stocks ended up on Tuesday, with each of the three major indexes posting their best one-day percentage gains in over a week, as lawmakers’ comments on tax reform and the debt ceiling boosted investor optimism.

U.S. House Speaker Paul Ryan told CNN at a town hall on Monday that tax reform would be easier to pass than the failed healthcare overhaul because Republicans have built a consensus.

Separately, Senate Majority Leader Mitch McConnell said on Monday that there was “zero chance” that the United States will fail to raise the debt ceiling in September, allaying concerns that the United States is poised to default on its debt, according to media reports.

“Definitely part of today’s movement is rumblings of the potential for tax reform or tax repatriation,” said Eric Freedman, chief investment officer at U.S. Bank Wealth Management in Minneapolis.

“If we have more of a messy debt ceiling debate and sides become firmly entrenched, that could spell out more difficulty, both within the party and between parties.”

Investors are also looking for positive hints on U.S. monetary policy from Federal Reserve Chair Janet Yellen on Friday at the annual central bankers meeting in Jackson Hole, Wyoming, though observers do not expect her to give new guidance.

Absent major news from the White House and a standstill in tensions between the United States and North Korea – two major factors that roiled the market in the past two weeks – investors flocked back to high-flying tech shares.

Traders work on the floor of the New York Stock Exchange (NYSE) in New York, U.S., August 17, 2017. REUTERS/Brendan McDermid

Gains were broad, with nearly all of the 11 major S&P sectors posting gains. Technology .SPLRCT shares led the advance, up 1.5 percent, notching the first gain in four sessions.

The S&P 500 materials .SPLRCM index also jumped more than 1 percent, enjoying its best day since mid-June, led by rising commodity and metals prices.

Metals prices, including copper CMCU3, zinc CMZN3 and nickel CMNI3, ended higher against a backdrop of strong results for mining firms and talk of shortages in some metals. [MET/L]

The Dow Jones Industrial Average .DJI rose 196.14 points, or 0.9 percent, to 21,899.89, the S&P 500 .SPX gained 24.14 points, or 0.99 percent, to 2,452.51 and the Nasdaq Composite .IXIC added 84.35 points, or 1.36 percent, to 6,297.48.

At the close, 335 stocks hit new 52-week highs while 300 hit fresh 52-week lows across all U.S. exchanges, marking the first time in 10 sessions that more stocks have hit highs than lows.

Among stocks, Freeport-McMoRan Inc FCX.N gained 2.31 percent on news that Indonesia expects to strike an agreement this month to allow the miner to keep operating its copper mine in Papua.

Macy's Inc M.N rose 4.56 percent, scoring its best day in nearly seven months, after announcing restructuring and job cuts.

DSW Inc DSW.N shares surged 17.46 percent after the footwear retailer reported a surprise rise in comparable sales.

Advancing issues outnumbered declining ones on the NYSE by a 2.66-to-1 ratio; on Nasdaq, a 2.40-to-1 ratio favored advancers.

About 5.24 billion shares changed hands in U.S. exchanges, below the 6.28 billion daily average over the last 20 sessions.