Federer fights back to reach Swiss quarter-finals