I’ve prepared a patch implementing an idea of the optimization which eliminates checks with known exit count (basically these are checks against the inductive variable) using unrolling. So far I’ve framed it as a separate pass in patch https://reviews.llvm.org/D97357. In looks a lot like it can be made a part of unrolling, but looking into intricacies of its code, I could not find the right way to frame it there. I’d appreciate any ideas on what is the right place to make this transform, does it make sense to teach Unroll Pass doing such things (and making its code even more complex) or it’s worth keeping it separately?
Any input appreciated.