https://github.com/wangpc-pp approved this pull request. LGTM. I still feel uncomfortable about the complexity (too many conditions, and I personally prefer straightforward definitions) but I think we can improve it progressively. https://github.com/llvm/llvm-project/pull/143938