https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99881
--- Comment #2 from H.J. Lu <hjl.tools at gmail dot com> --- Created attachment 50501 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50501&action=edit A patch to add vec_contruct cost ix86_builtin_vectorization_cost has case vec_construct: { /* N element inserts into SSE vectors. */ 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); /* One vinserti64x4 and two vinserti128 for combining SSE and AVX256 vectors to AVX512. */ else if (GET_MODE_BITSIZE (mode) == 512) cost += 3 * ix86_vec_cost (mode, ix86_cost->addss); return cost; } Add vec_contruct cost for vec_construct operation.