Gym attacking - it doesn't really matter, as a few power ups extra will make a low IV attacker just as strong as a high IV attacker. That being said, those extra power ups cost stardust and candy, so it makes more sense to power up higher IV attackers, and the higher the better to save on resources.
Prestiging - IV is irrelevant, as you are just shooting for 1000 prestige against everything but Blissey
Defending - IV is everything if you are maxing a high CP defender and need to get as far from the bottom of the gym as possible. That being said, an 82% Tyranitar is still going to out max CP a 100% Snorlax, so the need varies by species and your areas typical defenders.