Anderson failed to break Federer's serve in the match, which lasted just more than an hour. He had 21 unforced errors while Federer hit 17 winners and won 79 percent of his first-serve points.
Federer cooled off Anderson, who ended Australian Open champion Stanislas Wawrinka's 13-match winning streak in the fourth round here. Federer earned the only break in the first set in the last game, when Anderson netted a backhand volley.
"It was big to win the set and then to go on to break early in the second," Federer said. "Then double break was like a bonus. From then on I was home, basically. It was a really good match for me."
By then, Federer was on his way to winning 13 straight points. He broke Anderson twice in taking a 4-0 lead in the second set, having won seven consecutive games over both sets. Anderson did his best to trade groundstrokes with Federer while looking for an opening to rush the net, but the South African's repeated errors spoiled his game plan.
Dolgopolov's win assured the Ukrainian of rising to a projected No. 23 in next week's ATP Tour rankings. Already, he has made the biggest jump in the top 50, moving up 26 spots since the end of last year to No. 31 before the tournament began.
"Obviously if you're ranked 20, 30, 40, you're a good enough player. To get in the top 10, you just need all those small things to be together and to be solid," he said. "It's really small differences from the players that are top 10 and top 50. I don't think I changed a lot, and it's working good; I'm staying healthy; I'm doing all the things I did but a little bit better."
Dolgopolov improved to 6-2 against top-20 opponents this year, including his third-round win over top-ranked Rafael Nadal.
Raonic took out fourth-ranked Andy Murray in three sets in the fourth round, but he couldn't follow it up win a win over Dolgopolov in their first meeting.