Valence and magnetic instabilities in Sm compounds at high pressures