WARSAW — President Trump criticized China on Wednesday for failing to do more to pressure North Korea on its nuclear program, suggesting as he prepares for a high-stakes meeting with the Chinese president, Xi Jinping, this week that he is re-evaluating the United States trade relationship with Beijing in light of the growing provocations from Pyongyang.

Mr. Trump vented his displeasure with China in a pair of early-morning tweets as he was departing on a trip to Warsaw, and to Hamburg, Germany, for the Group of 20 gathering of major world economies, where discussions about how to deal with the North Korean threat will be high on the agenda. He plans to hold meetings on the sidelines with Mr. Xi, as well as with Prime Minister Shinzo Abe of Japan and President Moon Jae-in of South Korea.

“Trade between China and North Korea grew almost 40% in the first quarter,” Mr. Trump said in one of the tweets on Wednesday. “So much for China working with us — but we had to give it a try!”

A few minutes earlier, he suggested that American trade agreements should be contingent on such cooperation.