topperc wrote: This optimization is not correct for 'undef'. I think it would be correct for 'poison', but SelectionDAG doesn't have 'poison' today. See also https://blog.regehr.org/archives/1837 https://github.com/llvm/llvm-project/pull/115451