The previous logic didn't always know how to handle bitcasts of integer vectors with some undef elements.
The problem only affected the case where the bitcast vector type had more packed elements than the input vector type.
Example:
%cast = bitcast <2 x i64> <i64 undef, i64 2> to <4 x i32>
On a little endian target, that bitcast could be folded into the following constant vector:
<4 x i32><i32 undef, i32 undef, i32 2, i32 0>
However, the input vector had some undef elements, and the constant folder didn't know how to handle them.
This patch improves the logic by teaching how to deal with undefs.
Please let me know if okay to commit.
Thanks,
Andrea