Slightly improves the precision of GlobalsAA in certain situations, and makes the behavior of optimization passes more predictable.
How about pulling this out of the loop? That is, do:
if (auto *C = dyn_cast<Constant>(V)) if (!C->isConstantUsed()) return false;
Some more context here will be helpful -- are you trying to check if the load was hoisted out of the loop? If so, then a CHECK: entry: before the load will be nice (since there are two instances of br label %for.inc).
That wouldn't work... say V is the global @a (with live loads and stores which access it), and I is a constant expression ptrtoint @a to i32. We want to ignore I if it's dead; checking V is useless.
Yes; I'll change this to make that more clear.