Iga Swiatek recovered from losing the opening set to beat Kostyuk and reach the last eight in Toronto.