Phonon self-energies and the gap of high-temperature superconductors