https://github.com/kasuga-fj commented: Thanks (actually, I found the same problem recently and was trying to fix it, so thanks for the help). The algorithm looks good to me. I left a few minor comments, could you check them out? https://github.com/llvm/llvm-project/pull/105475