The value lattice explicitly represents undef, and markConstant() internally checks for UndefValue and will create an undef rather than constant lattice element in that case.
This is mostly a code simplification, it has little practical impact because we usually get undef results from undef operands, and those don't get processed.
Only leave the check behind for the CmpInst case, because it currently goes through this incorrect code in the getCompare() implementation: https://github.com/llvm/llvm-project/blob/f98697642cea761448dc0f84f750d3f5def8af6b/llvm/include/llvm/Analysis/ValueLattice.h#L456-L457