https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127345
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> --- // VIEW_CONVERT_EXPR works like a cast between integral values. // If the number of bits are not the same, behaviour is undefined, // so cast behaviour still works. is not true. The number of bits can be different (TYPE_PRECISION), just TYPE_SIZE needs to be the same. So, I think this optimization is only correct if TYPE_PRECISION is the same.
