Gain nonlinearities in semiconductor lasers and amplifiers