d-wave superconductivity and pomeranchuk instability in the two-dimensional hubbard model