LoopVectorize: Emit reductions as log2(vectorsize) shuffles + vector ops instead...
authorBenjamin Kramer <benny.kra@googlemail.com>
Tue, 18 Dec 2012 18:40:20 +0000 (18:40 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Tue, 18 Dec 2012 18:40:20 +0000 (18:40 +0000)
commitf0e5d2f032496b9484c7634cb127b2d645d4b337
treeaef57a2bccdb563e43c456e166f8ef630f908658
parent39e7c6e370ffaf941503cd8b3f54767e4e7fa886
LoopVectorize: Emit reductions as log2(vectorsize) shuffles + vector ops instead of scalar operations.

For example on x86 with SSE4.2 a <8 x i8> add reduction becomes
movdqa %xmm0, %xmm1
movhlps %xmm1, %xmm1            ## xmm1 = xmm1[1,1]
paddw %xmm0, %xmm1
pshufd $1, %xmm1, %xmm0        ## xmm0 = xmm1[1,0,0,0]
paddw %xmm1, %xmm0
phaddw %xmm0, %xmm0
pextrb $0, %xmm0, %edx

instead of
pextrb $2, %xmm0, %esi
pextrb $0, %xmm0, %edx
addb %sil, %dl
pextrb $4, %xmm0, %esi
addb %dl, %sil
pextrb $6, %xmm0, %edx
addb %sil, %dl
pextrb $8, %xmm0, %esi
addb %dl, %sil
pextrb $10, %xmm0, %edi
pextrb $14, %xmm0, %edx
addb %sil, %dil
pextrb $12, %xmm0, %esi
addb %dil, %sil
addb %sil, %dl

llvm-svn: 170439
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/test/Transforms/LoopVectorize/reduction.ll