https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128938
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Keywords| |code-size
Last reconfirmed| |2026-11-23
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
_9 + sum_22 2 times vector_stmt costs 8 in epilogue
_9 + sum_22 1 times vec_to_scalar costs 16 in epilogue
that's
# vect_sum_18.23_113 = PHI <vect_sum_18.23_112(3)>
_114 = VEC_PERM_EXPR <vect_sum_18.23_113, { 0, 0 }, { 1, 2 }>;
_115 = _114 + vect_sum_18.23_113;
_116 = BIT_FIELD_REF <_115, 32, 0>;
and
psrlq $32, %xmm1
paddd %xmm1, %xmm0
movd %xmm0, %ecx
the issue is more likely the unpacking of 8 chars to vector(2) int vectors.
And yes, costing is mostly about speed, we have no special consideration
for size besides avoiding some of the versioning/peeling at -O2.
Note we're not using a vector epilog with V4QI as that would result in
V1SI which we refuse in vect_make_slp_decision:
/* If all instances ended up with vector(1) T roots make sure to
not vectorize. RVV for example relies on loop vectorization
when some instances are essentially kept scalar. See PR121048. */
if (SLP_TREE_VECTYPE (root)
&& known_gt (TYPE_VECTOR_SUBPARTS (SLP_TREE_VECTYPE (root)), 1U))
decided_to_slp++;
that's probably a bit overzealous when VF != 1 as well. Allowing that we
run into
t.c:1:5: missed: not vectorized: relevant stmt not supported: patt_58 = (int)
patt_57;
so the V2HI -> V1SI mode unpacking isn't supported by the target.
Of course you say the reduction should be narrowed to HImode but we can't
currently do that - there have been hacks^Wpatches posted for this but not
in mergeable state IMO.