In theory, one should use the horizontal distance in accordance with the rifleman's rule.
However, barrels bend very slightly under the force of gravity. When you point them up or down, they spring up a little, shooting slightly higher.
Different guns have different barrels and different ways of supporting them. The only way to know for sure, is to place targets at different distances/heights and record where the impact points are.