US stocks gained on Wednesday as Nvidia Corp., the top-weighted S&P 500 Index stock, climbed ahead of the chipmaker’s earnings report after the market close.