--- gcc/tree-vect-stmts.c	(revision 162467)
+++ gcc/tree-vect-stmts.c	(working copy)
@@ -1862,6 +1862,7 @@ vectorizable_assignment (gimple stmt, gi
     = get_vectype_for_scalar_type (TREE_TYPE (gimple_assign_lhs (stmt)));
   if (CONVERT_EXPR_CODE_P (code)
       && (!vectype_in
+	  || !vectype_out      
 	  || (TYPE_VECTOR_SUBPARTS (vectype_out)
 	      != TYPE_VECTOR_SUBPARTS (vectype_in))
 	  || (GET_MODE_SIZE (TYPE_MODE (vectype_out))
--- gcc/testsuite/gcc.c-torture/compile/pr45047.c	(revision 0)
+++ gcc/testsuite/gcc.c-torture/compile/pr45047.c	(revision 0)
@@ -0,0 +1,9 @@
+/* PR tree-optimization/45047 */
+
+void
+foo (const unsigned short *w, char *x, int y, int z)
+{
+  int i;
+  for (i = 0; i < y; i++)
+    x[i] = w[i] == z;
+}
