Screenwriters Christopher Markus and Stephen McFeely have confirmed that Mark Ruffalo's Professor Hulk was originally going to make his debut in Avengers: Infinity War's final battle. During the Writing Avengers: Endgame panel at San Diego Comic-Con 2019, Markus revealed that a scene was shot where Hulk burst out of the Hulkbuster armor and "kicked Cull Obsidian's ass" - but it was ultimately cut from the movie.
In the final cut of Avengers: Infinity War, Hulk doesn't appear at all after his initial battle with Thanos on board the Asgardians' ship. Whenever Bruce Banner tries to bring out his other half, the Hulk refuses. When it comes time to fight Thanos and his army again at the Battle of Wakanda, Bruce puts on Tony Stark's Hulkbuster armor so that he can join the fray. Trailers for Avengers: Infinity War showed the Hulk himself fighting alongside his fellow Avengers in all his green glory, and while these were assumed to simply be one of the deliberately misleading trailer elements, they may actually have been left over from an earlier version of the movie.
Professor Hulk (or "Smart Hulk") is a union of the two halves of Bruce Banner's personality: Dr. Banner's brains inside the Hulk's brawny body. In Avengers: Endgame it's revealed that he achieved this union after spending 18 months in a gamma lab. However, Markus said that in the early version of Avengers: Infinity War, Bruce and Hulk united spontaneously while Bruce was inside the Hulkbuster armor, and there was a scene where the Hulk burst free as he transformed. As for why it was cut, Markus explained, "It didn't work! It was completely the wrong tone for that moment in the movie. It was this moment of victory while we were headed toward defeat."
By the time Professor Hulk was cut from Avengers: Infinity War, Avengers: Endgame had already been shot, so it needed a slight rewrite to explain the existence of this smarter version of the big green guy - which was why Markus and McFeely came up with the line about Banner working in the gamma lab. Markus said that they didn't want to go much deeper into the explanation than that:
"You don't have to explain as much as you think you have to. Okay, he's the culmination of Hulk and Banner, just give me a crumb to hold on to... Part of the challenge and part of the pleasure... of these two movies... is how do you tell everything you need to tell... and keep it light enough you're not bogging it down?"
We had previously guessed that Professor Hulk was going to be in Avengers: Infinity War from the tie-in merchandise and toys for the movie. The Hulk Out Hulbuster toy from Hasbro actually has the Hulk bursting out of the Hulkbuster armor, and features distinctly un-Hulk-like dialogue such as "According to my calculations, this is gonna hurt you," and "I'm still mean and green, smashing you is nothing personal, it's just kind of my thing." Details like this just go to show how, as Markus explained, Avengers: Infinity War and Avengers: Endgame were being tinkered with right up until their release.