Local and average structural evolution of halide perovskites upon compression