
The 33-year-old, 17-time Grand Slam winner was pushed to three sets in the previous round by Philipp Kohlschreiber but had fewer problems with Gulbis.
He will now meet Germany's Florian Mayer, who defeated American Steve Johnson 6-3, 7-6 (7/4).
Federer joked that he was in better form than world number one Novak Djokovic -- the man he lost against in last year's Wimbledon final.
"Yes, because I've won two matches on grass and he hasn't won any yet," said the Swiss in reference to Djokovic's decision not to play a grass-court event before Wimbledon.
"Kidding aside, yes, I hope to be competitive. I hope I'm going to be in good shape. I hope we play against each other (at Wimbledon).
"That probably means we are in the final both of us and we're both equally pleased with the tournament. But we know how long that road is to get there. I think our games both work very well on grass. AFP