If we cannot fix up the block placement of WLS branches we revert WLS to DLS instructions. But in doing so can create new blocks, invalidating loop analyses and potentially running into invalid iterators. Prevent that by creating a list of all WLS instructions to revert and reverting them after processing all loops.
The test case it fairly large, but I have not managed to simplify it any further due to the issue coming up from invalid iterators.
Nit: perhaps add a comment why we are adding/doing this bookkeeping (i.e. the description of this patch).