Stocks gave back the bulk of gains on Thursday afternoon as Donald Trump prepared to meet with China's President Xi Jinping for a two-day summit. 

The S&P 500 was up 0.05%, the Dow Jones Industrial Average added 0.04%, and the Nasdaq rose 0.04%.

Trump and President Xi are scheduled to meet on Thursday and Friday at Mar-a-Lago in Florida in what are expected to be a highly charged discussions. Trump had been highly critical of China, accusing the country of currency manipulation and unfair trade practices. Trump had previously proposed a high tariff on U.S. imports of Chinese-made products. North Korea also will presumably be an important topic of conversation.

"It is imperative to watch if U.S. President Trump acts within his protectionist rhetoric or if he eventually shows a more cooperative stance like how he did with his meetings with U.K. Prime Minister Theresa May and Japan Prime Minister Shinzo Abe," said Phillip Futures' Woon Tian Yong. "It is also important to sieve out China's management of its relationship with the United States under Trump, and its positions following the meeting."

Wall Street grew nervous on Thursday afternoon after Trump and Secretary of State Rex Tillerson signalled possible military action in Syria. Tillerson said the U.S. was considering the "appropriate response" to the chemical attack in Syria on Tuesday that killed dozens. Trump said "something should happen" in Syria regarding President Bashar al-Assad's leadership. 

Energy stocks were the best performers Thursday as crude oil prices rose for their third day in a row. The commodity and the energy sector had a rocky session on Wednesday after a weekly reading on domestic inventories showed an unexpected rise in stockpiles.

West Texas Intermediate crude was up 1.1% to $51.70 a barrel on Thursday, while major oilers including Exxon Mobil (XOM - Get Report) , Royal Dutch Shell (RDS.A - Get Report) , Total (TOT - Get Report) and Petrobras (PBR - Get Report) rose. The Energy Select Sector SPDR ETF (XLE - Get Report) increased 1%.

"The petroleum markets are testing the upside in Thursday dealings, with market sentiment apparently passing the test posed by Wednesday's mix of weaker-than-expected U.S. inventory numbers," said Tim Evans, energy futures specialist at Citi, in a note. "On balance, we think the market's rebound off the March lows, while impressive, may be also expanding the downside risk."

Wall Street ended lower on Wednesday, falling into the red in the final hour, after the Federal Reserve committed to further monetary tightening this year. In the minutes from the Fed's meeting in March, it was revealed the central bank could reduce its balance sheet this year, plus hinted at the possibility of ending its policy of reinvesting principal payments. Reducing the balance sheet could have the same impact on the markets as a rate hike. The Fed currently holds $4.5 trillion in bonds on its balance sheet.

Jim Cramer and four of TheStreet's top columnists discuss how to play Fed rate hikes and the second quarter's likely rising interest-rate environment.

Markets have also been in churn mode over the past few days, Wednesday excluded, as investors awaited hints of progress on tax reform from the Trump administration. Trump has frequently promised an overhaul of the tax code, though details of his plans have remained vague.

"The mood of the market is basically 'wait and see'... with respect to what the shape and timing of fiscal reform will be in terms of tax cuts and regulatory reform," Ernie Cecilia of Bryn Mawr Trust told TheStreet. "When we go through our evaluation templates for companies, when you start adjusting the corporate tax rate the valuation implications are significant amounts."

Trump's ability to work the political system was called into question, though, after his Obamacare repeal and replace bill was pulled before a congressional vote in March. Trump and House Speaker Paul Ryan had failed to secure the necessary number of votes for the bill to pass the House. Ryan said on Wednesday that tax reform will take longer than a health care bill, noting that the House, Senate and White House were on different pages when it came to their plans' development. 

The official jobs report for March, one of the most closely watched monthly datum, will be released on Friday. A massive beat on private payrolls numbers from ADP kept investors in good spirits ahead of Friday's release, though a late-season snow storm could impact the numbers. Analysts anticipate no drop in recent strength in the labor market with a target of 174,000 jobs expected to have been added to U.S. payrolls last month. The unemployment rate is anticipated to have held at 4.7%, while monthly wages should rise 0.3%.

Weekly jobless claims showed a big decline in the past week. The number of new claims for unemployment benefits fell by 25,000 to 234,000. The less volatile four-week average dropped 4,500 to 250,000. 

Bed, Bath & Beyond (BBBY - Get Report) increased 3.7% after topping analysts' estimates in its recent quarter. The homewares retailer earned $1.84 a share, down from $1.91 in the year-ago quarter but above targets of $1.77. Comparable-store sales increased 0.4%, while overall sales rose to $3.5 billion from $3.4 billion in the year-ago quarter.  

Yum! China (YUMC - Get Report) surged more than 8% on first-quarter earnings that were better than anticipated. The owner of KFC in China earned 44 cents a share, 6 cents above consensus. Sales of $1.28 billion exceeded estimates of $1.27 billion, while same-store sales increased 1%. 

CarMax (KMX - Get Report)  rose 2.3% after reporting a double-digit gain in quarterly earnings. Net income of 81 cents a share was 14% higher than a year earlier and topped estimates of 79 cents. Sales increased just over 9% to $4.05 billion and came in higher than a target of $3.93 billion. The retailer expects to open 15 new locations in fiscal 2018. 

Constellation Brands (STZ - Get Report)  jumped 6.5% on Thursday after a better-than-expected fourth quarter. The alcohol company earned net income of $2.26 a share, up from $1.48 a share in the year-ago quarter. Sales of $1.63 billion exceeded estimates of $1.59 billion. For fiscal 2018, the company anticipates earnings of at least $7.65 a share.  

Sunoco (SUN - Get Report) rose 18% after Seven & I Holdings, the Japanese owner of 7-Eleven, announced on Thursday it was buying parts of Sunoco's convenience store and gas station business for $3.3 billion.

SeaWorld (SEAS - Get Report) was initiated with a sell rating and $16 price target at Goldman Sachs. Analysts are skeptical that cost-cutting measures will translate to growth.

Cardinal Health (CAH - Get Report) , the U.S. drug distributor, is reportedly  nearing a deal to acquire the medical supplies business of Medtronic (MDT - Get Report) for close to $6 billion. Medtronic and Cardinal Health have entered into exclusive talks over the sale of the business, and a deal could be announced later this month, sources told Reuters 

Advanced Micro Devices (AMD - Get Report)  fell 7% after Goldman Sachs initiated coverage with a sell rating and $11 price target. The stock has already priced in a definite improvement in its financial situation and current valuation metrics make it "difficult" to justify, Goldman analyst Toshiya Hari wrote.

Costco (COST - Get Report) rose 2% after reporting strong sales figures for March. The warehouse retailer said sales in the U.S. in March increased 9% to $11.64 billion, while same-store sales increased 7%. Excluding gas prices and currency exchange, comparable sales in the U.S. increased 6%. 

L Brands ( LB - Get Report) surged 10% even after reporting a steep decline in March sales. Sales in March declined by 7% to $951.4 million. Comparable sales for the five weeks to April 1 dropped 10%.