Grigor Dimitrov stuns Carlos Alcaraz 5-7 6-2 6-4 to reach the quarter-finals of the Shanghai Masters.