Medical ultrasound imaging systems rely on a presumed sound speed to calculate the delay compensation of each array element for coherent receive focusing. However, due to mismatch between the tissue sound speed (Ctissue) and the beamforming sound speed (Cbeam), the phase coherence across the array is often compromised and the resultant image quality degrades. In order to alleviate the sound speed mismatch, differential phase gradient between sub-apertures is proposed in this study by using channel-domain autocorrelation to estimate the optimal sound speed for beamforming. Simulations of point reflector show that the differential phase gradient approaches zero whenever Cbeam is set to Ctissue. In experiments using speckle phantom, the optimized sound speed is estimated to be 1420 m/s compared to the nominal sound speed of 1450 m/s. The corresponding B-mode images at 7 MHz show that the optimization of sound speed reduces the -12-dB lateral width of point spread function from 0.94 mm to 0.71 mm. The image contrast between cyst and background also peaks near the optimized sound speed. Compared to minimum average phase variance (MAPV) method, the proposed method is more robust by reducing the coefficient of variation from 0.5 % to 0 %.