The win in 80 minutes puts the 34-year-old Swiss into clear secondposition in the all-time match win category as he earned his 1,072ndvictory. Jimmy Connors still leads the table on 1,256.
Federer kept Mayer at a distance as he beat the German for theseventh time without a loss in their series.
The Swiss will Saturday play Austrian Dominic Thiem after the thirdseed made a comeback over Russian Mikhail Youzhny 3-6, 6-4, 7-5.
"The feeling was better, I felt I was playing up and down the courtmore, coming to the net and seeing thing s bit better," Federer said.
"My serve was more consistent and accurate and I played two goodtiebreakers. I'm very pleased, this was a stp up form the alstmatch."
In the other quarter-finals, Argentine Juan Del Potro continued aninjury comeback, beating fourth seed Gilles Simon 6-7 (3-7, 6-4, 6-0while German seventh seed Philipp Kohlschreiber stopped Czechqualifier Radek Stepanek 6-4, 7-5.
Federer is on court for the first time since losing to Thiem on Romeclay a month ago, plagued with back pain. Federer skipped the FrenchOpen to deal with the medical issue and is now in a race for time tobe ready on grass for the start of Wimbledon in just over threeweeks.
Federer won with 15 aces for his 13th victory of an injury-shortenedseason.
Thiem earned what he called his career-best grass court victory as hebeat Youzhny and reach his first-ever grass semi.
Thiem, the world number seven thanks to a French Open semi-final lastweek, next face Federer.
Thiem won only his fourth career grass match, going through in notquite two hours.
"This was the biggest win of my career on grass," Thiem said afterbeating the 2002 Stuttgart champion (on clay). "There were a lot ofups and downs. I was close to losing in the second set with breakpoints and at 5-5 in the third.
"I'm happy with my fighting spirit and happy with this whole win."
The 22-year-old winner was stunned by his level on the unfamiliarsurface: "Grass is different for me. I'm unbelievably happy with thissemi-final. Anything that comes now is a big bonus.
"It's not nice to play Roger on any surface. He is the best on grass.Against him, I have no expectations."
Thiem beat an ailing Federer on Rome clay in May, but said that upsetmeans little: "Clay is my surface, I feel very confident againstalmost all players."
Thiem now stands 4-6 on grass as he scored his first back-to-backwins on the lawns with 11 aces.