In LinearFunctionTestReplace, it seems like if we conclude that it is unsafe to insert a comparison because the induction variable is poison, we don't emit the overflowing addition, but emit the LFTR with an incorrect IVCount anyway. I've added a test case lftr-bad-ivcount.ll that demonstrates the bug.
There are a handful of unit tests that need to be fixed with this change (so if you just apply this patch, make check will fail), but first I'd like to get a sanity check on whether this is a bug or if I've misunderstood something.