The posted a four-day losing streak on Wednesday — its longest slide since early May — as investors braced for a key meeting between President Donald Trump and Chinese President Xi Jinping later this week.

The broad index closed 0.1% lower at 2,913.78, giving up gains from earlier the day. The Dow Jones Industrial Average fell 11.40 points to 26,536.82 after rising more than 100 points to start off the session.

The Nasdaq Composite outperformed, rising 0.3% to 7,909.97 as Micron shares led semiconductor stocks higher. The VanEck Vector Semiconductor ETF (SMH) climbed nearly 3% as Micron surged more than 13%. Nvidia rose 5.1% while On Semiconductor climbed 4.2%.

Stocks traded higher for most of Wednesday's session after Treasury Secretary Steven Mnuchin told CNBC's Hadley Gamble he thinks "there's a path" for the U.S. and China to complete a trade deal. His comment came ahead of a meeting between President Donald Trump and Chinese President Xi Jinping at the G-20 summit in Osaka, Japan later this week.

"This clearly highlights how the escalation of the trade conflict in May negatively impacted stock returns while a trade resolution will lift them back up," said Nick Raich, CEO of The Earnings Scout, in a note. However, "this is not new talk from Mnuchin."

Bloomberg News also reported, citing sources, that the U.S. was willing to suspend tariffs on $300 billion worth of Chinese goods as the two sides resume trade talks.

Trump told Fox Business that a U.S.-China trade deal was possible, but noted he is "very happy with where we are now. We're taking in a fortune, and frankly [it's] not a very good thing for China, but it is a good thing for us."

Trade talks stalled last month after the U.S. hiked tariffs on billions of dollars worth of Chinese imports. China retaliated with tariffs of its own. Those fears dissipated in June after Trump said he and Xi agreed to meet at the G-20, stoking hope of trade progress between the two countries.