As noted here https://lists.llvm.org/pipermail/llvm-dev/2016-October/106182.html and by alive2, this transform isn't valid. If X is poison this potentially propagates poison when it shouldn't.
It seems we don't have any tests for this in either InstSimplify or InstCombine. I can add negative tests if we want.
The same transform also exists in DAGCombiner.
Can we still do these optimizations when X is a frozen value?