US stocks end midweek with gains ahead of Nvidia earnings