https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101944
--- Comment #1 from Kewen Lin <linkw at gcc dot gnu.org> --- The original costing shows the vectorized version wins, by checking the costings, it missed to model the cost of lane extraction, the patch was posted in: https://gcc.gnu.org/pipermail/gcc-patches/2021-August/577422.html With the proposed adjustment above, the costings become to: reduc.c:24:34: note: Cost model analysis for part in loop 0: Vector cost: 17 Scalar cost: 17 Now we consider vectorization is still profitable when both cost are equal, so the SLP still performs. One thing can make it different is that: when we do costing, math optimization doesn't happen, there are no FMA-style operations, but finally some multiply and subtraction is optimized to FMS. If costing for scalar faces two multiply-and-sub (counted as 2) instead of two multiplies and subtractions (counted as 4), vs. vector costing 1 instead of 2. It ends up with scalar 15 vs. vector 16. But it seems not practical since we can't predict the later processing well, I tried to hack pass_optimize_widening_mul to run before slp, I saw it failed earlier.