Andy Murray edged closer to a third Miami Open title after reaching the semi-finals with a gritty victory over Dominic Thiem.