Does this patch need an update at llvm/test/Transforms/InstSimplify/select.ll as well? (relevant commit: https://github.com/llvm/llvm-project/commit/566a66703f020996d07191323ae8ad6f7ad827b3 )
Nevermind, it should be updated after the select undef fold is disabled.
Maybe it is because an operation on undef is already folded before expandBinOp is reached. Is it right @nikic? I think having a working test here likely means we found another miscompilation regarding undef and distributivity law.
If select c, undef, x --> x is disabled later, it will leave the undef constant, making the test at select.ll valid.