SCEV analysis cannot properly cache instruction with poison flags
(for example, add nsw outside of loop will not be reused by expander).
This can lead to generating of additional instructions by SCEV expander.
Example IR:
... %maxval = add nuw nsw i32 %a1, %a2 ...
for.body:
... %cmp22 = icmp ult i32 %ivadd, %maxval br i1 %cmp22, label %for.body, label %for.end ...
SCEV expander will generate copy of %maxval in preheader but without
nuw/nsw flags. This can be avoided by explicit check that iv count
value gives the same SCEV expression as calculated by LFTR.
nits:
auto *BI
auto *Cmp