https://github.com/nikic commented: At a high level, this seems like we should be able to handle it generically with a FoldOpIntoSelect-style transform, but that currently only works with a constant binop operand. https://github.com/llvm/llvm-project/pull/138373