Explaining the mechanism of superconductivity in the high-Tc cuprates requires an understanding of what causes electrons to form Cooper pairs. Pairing can be mediated by phonons, the screened Coulomb force, spin or charge fluctuations, excitons, or by a combination of these. An excitonic pairing mechanism has been postulated, but experimental evidence for coupling between conduction electrons and excitons in the cuprates is sporadic. Here we use resonant inelastic x-ray scattering to monitor the temperature dependence of the dd exciton spectrum of Bi2Sr2CaCu2O8−x crystals with different charge carrier concentrations. We observe a significant change of the dd exciton spectra when the materials pass from the normal state into the superconductor state. Our observations show that the dd excitons start to shift up (down) in the overdoped (underdoped) sample when the material enters the superconducting phase. We attribute the superconductivity-induced effect and its sign reversal from underdoped to overdoped to the exchange coupling of the site of the dd exciton to the surrounding copper spins.