TORONTO — Canadian and U.S. stock markets gained ground on Wednesday as oil prices fell and tech stocks rose on both sides of the border.