getAddExpr utility uses computed flags from AddRec plus loop invariants
in AddRec.Start + loop invariants basing on the an assumption that
0th iteration of the loop exists. However the loop might be dead
(runtime or compile time), in this case the propagation of the flag becomes
invalid.
To fix the bug we need to ensure that 0th iteration happens or use less
strict set of flags.
The patch uses the check for dominating all latches from used loops to ensure
that 0th iteration exists.
This comment is subtle, and almost correct, but not quite. We'd have to prove both that the loop loop is always taken, and that the values are defined in the function scope. (a.g. a GEP off a global pointer would require a non-function scope)