https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128923
--- Comment #17 from Hongtao Liu <liuhongt at gcc dot gnu.org> --- Now it generates 26.L5: 27 movq (%rsi), %xmm0 28 movq %xmm1, %xmm1 29 movq %xmm2, %xmm2 30 addq $16, %rsi 31 movss -8(%rsi), %xmm4 32 movaps %xmm0, %xmm7 33 minps %xmm2, %xmm0 34 movaps %xmm4, %xmm3 35 maxps %xmm1, %xmm7 36 maxss %xmm6, %xmm4 37 minss %xmm5, %xmm3 38 movaps %xmm0, %xmm2 39 movaps %xmm7, %xmm1 40 movaps %xmm4, %xmm6 41 movaps %xmm3, %xmm5 42 cmpq %rsi, %rdx 43 jne .L5 But the performance is still not as good as scalar version(from 1.5x to 1.3x) since there're two movq which has cross iteration dependence and slow down the whole loop. 28 movq %xmm1, %xmm1 29 movq %xmm2, %xmm2 The extra movq is generated by movq_v2sf_to_sse to avoid garbage in the upper 64 bits which may raise unexpected expection. ideally the cleanup of upper bits should be hoisted outside of the loop, the cross-iteration dependence make it complicated to be hosited out.
