Rules and mechanisms governing octahedral tilts in perovskites under pressure