This is a fix for:
https://bugs.llvm.org/show_bug.cgi?id=43730
...and as shown there, we have an existing test case that shows a potential miscompile.
We could just bail out for vector constants that contain any undef elements, or we can do as shown here:
allow the transform, but replace the undefs with a safe value.
For the tests shown, this results in a full splat constant (no undefs) which is probably a win for further IR analysis because we conservatively don't match undefs in most cases. Codegen can probably recover these kinds of undef lanes via demanded elements analysis if that's profitable.
This will result in the last one being used