This change does the plumbing to wire an ExitingBB parameter through the LFTR implementation, and reorganizes the code to work in terms of a set of individual loop exits. Most of it is fairly obvious, but there's one key complexity which makes it worthy of consideration. (The actual multi-exit LFTR patch is in D62625 for context.)
Specifically, it turns out the existing code uses the backedge taken count from before a IV is widened. This means that we can end up with a different a narrower BE count for the loop than requerying after widening.
For the nestedIV example from elim-extend, we end up with the following BE counts:
BEFORE: (-2 + (-1 * %innercount) + %limit)
AFTER: (-1 + (sext i32 (-1 + %limit) to i64) + (-1 * (sext i32 %innercount to i64))<nsw>)
This is the only test in tree which seems sensitive to this difference. The actual result of using the wider BETC on this example is that we actually produce slightly better code. :)
For the moment, the code is actually NFC. I'd like to land this as is, and then adjust the BETC used in a separate patch. (In particular, I want to investigate *why* they're different. They should be equivalent.) I'm open to being convinced that either a) I should investigate that first, or 2) I should just include the resultng test change in this commit and not worry about it. Thoughts?