Optimal Carrier Recovery and Detection on Frequency-Nonselective Fading Channels