Federer rallied to defeat Tommy Haas in their third-round match 1-6, 7-5, 6-3 and Nadal, with eight championship titles to his credit this year, outlasted Grigor Dimitrov 6-2, 5-7, 6-2.
Nadal and Federer have met twice this year with Nadal winning both matches -- at Masters Series tournaments in Rome and Indian Wells, Calif.
Nadal has a 20-10 all-time record against Federer. They have not met in a grand slam tournament since the 2011 French Open, where Nadal defeated Federer in the championship match.
Djokovic reached the quarterfinals with a 6-2, 6-0 decision over David Goffin. John Isner will face Djokovic after getting past Milos Raonic 7-6 (7-5), 6-4. Raonic was coming off an appearance in the finals last week at Montreal, where he fell to Nadal.