https://github.com/nikic commented: It would be better to support this in InstSimplify first (see simplifySelectWithICmpEq), because that's the base fold. The code in InstCombine handles complex cases that InstSimplify can't. https://github.com/llvm/llvm-project/pull/114975