The original check for load CSE or store-to-load forwarding is wrong
when the forwarded stored value happened to be a load.
The current logic was added in r241886. It looks safe but I'm wondering what kind of code pattern it used to mis-optimize. If there are two loads from the same address marked with either metadata, shouldn't it be valid to keep either of them? (After all, either of them had better be valid to start with).
Nit: "cast<LoadInst>()".