For my own edification I continued to think about the issue of potential energy gain and loss and I realise it depends on the interatomic forces within the spring.
Cooling the compressed spring reduces the vibrations of the atoms in the spring, and allows the interatomic forces to strengthen bonds among atoms and therefore shift them into lower energy states. As a result the atoms collectively act to make the spring more rigid so the potential energy stored in the compressed spring increases. Warming the compressed spring increases the vibrations of the atoms in the spring, and works against the interatomic forces to weaken bonds among atoms and therefore shift them into higher energy states. As a result the atoms collectively act to make the spring less rigid so the potential energy stored in the compressed spring decreases. This doesn't mean I think the principle of conservation of energy is universally true, but I try to understand what I don't accept. Harry