[PATCH] [SLPVectorizer] Reorder operands of shufflevector if it can result in a vectorized code.
Karthik Bhat
kv.bhat at samsung.com
Mon Jan 12 22:08:33 PST 2015
Hi Michael,
While still at this patch fix one more issue(small change) originally present in reorderInputsAccordingToOpcode.
In reorderInputsAccordingToOpcode AllSameOpcodeLeft and AllSameOpcodeLeft should return true if all the opCode on left and right respectively are same. But alas in the code we can see that in the loop we are resetting the value to-
AllSameOpcodeLeft = I0;
AllSameOpcodeRight = I1;
for each iteration. As a result we end up checking if the last 2 instructions have the same opcode in left and right.
As a result a code such as -
void foo(float* restrict a,float* restrict b,float* restrict c, float* restrict d)
{
a[0] = (b[0]+c[0])+d[0];
a[1] = d[1]+(b[1]+c[1]);
a[2] = (b[2]+c[2])+d[2];
a[3] = (b[3]+c[3])+d[3];
}
results in unoptimal vectorization as it considers all opcode on left and right to be same(since the last 2 have same opcode on left and right) and doesn't reorder the 2nd instruction which could have resulted in a better vectorized code.
This updated patch fixes this issue and added a test case for the same.
Please let me know your inputs on the same.
Thanks and Rergards
Karthik Bhat
REPOSITORY
rL LLVM
http://reviews.llvm.org/D6677
Files:
lib/Transforms/Vectorize/SLPVectorizer.cpp
test/Transforms/SLPVectorizer/X86/addsub.ll
test/Transforms/SLPVectorizer/X86/operandorder.ll
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6677.18074.patch
Type: text/x-patch
Size: 23373 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150113/1a69ec5e/attachment.bin>
More information about the llvm-commits
mailing list