===================================================================
@@ -45173,9 +45173,8 @@ ix86_builtin_vectorization_cost (enum ve
case vec_construct:
{
- gcc_assert (VECTOR_MODE_P (mode));
/* N element inserts into SSE vectors. */
- int cost = GET_MODE_NUNITS (mode) * ix86_cost->sse_op;
+ int cost = TYPE_VECTOR_SUBPARTS (vectype) * ix86_cost->sse_op;
/* One vinserti128 for combining two SSE vectors for AVX256. */
if (GET_MODE_BITSIZE (mode) == 256)
cost += ix86_vec_cost (mode, ix86_cost->addss);
===================================================================
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-slp-vectorize -fno-vect-cost-model -mno-sse" } */
+
+int x;
+
+void foo (short a, short b)
+{
+ ((short *)&x)[0] = a;
+ ((short *)&x)[1] = b;
+}
+
+#if __SIZEOF_LONG__ == 8
+long y;
+
+void bar (short a, short b)
+{
+ ((short *)&y)[0] = a;
+ ((short *)&y)[1] = b;
+ ((short *)&y)[2] = a;
+ ((short *)&y)[3] = b;
+}
+#endif