https://github.com/fhahn approved this pull request. LGTM, thanks. Some touched comments should probably be updated to explain both increasing and decreasing cases, added some more comments inline https://github.com/llvm/llvm-project/pull/146386