[PATCH] Improve Cost model for SLPVectorizer when we have a vector division by power of 2
Karthik Bhat
kv.bhat at samsung.com
Tue Aug 19 06:34:01 PDT 2014
Hi nadav, aschwaighofer, hfinkel,
Hi All,
This patch improves the cost model in SLPVectorizer for division by power of 2. Currently the below code is not vectorized by clang in O3. Gcc though is able to vectorizes this.
void f(int* restrict a,int *restrict b,int *restrict c ) {
a[0] = (b[0]+c[0])/2;
a[1] = (b[1]+c[1])/2;
a[2] = (b[2]+c[2])/2;
a[3] = (b[3]+c[3])/2;
}
The problem is SLPVectorizer estimates the cost of vector divide as too high to be profitable and gives up on vectorization.
But in cases such as the above were we are dividing by power of 2 the cost infact is much less as backend converts them into instruction such as psrad/psraw on X86 targets.
The current patch updates the cost model when we divide by power of 2 to enable vectorization in such cases.
Please let me know your i/p's on the same.
Thanks and Regards
Karthik Bhat
http://reviews.llvm.org/D4971
Files:
include/llvm/Analysis/TargetTransformInfo.h
lib/Target/X86/X86TargetTransformInfo.cpp
lib/Transforms/Vectorize/SLPVectorizer.cpp
test/Transforms/SLPVectorizer/X86/powof2div.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4971.12663.patch
Type: text/x-patch
Size: 6035 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140819/0549c20c/attachment.bin>
More information about the llvm-commits
mailing list