[LLVMdev] Packed instructions generaetd by LoopVectorize?
Nadav Rotem
nrotem at apple.com
Wed Apr 3 10:33:08 PDT 2013
Hi Tyler,
Try adding -ffast-math. We can only vectorize reduction variables if it is safe to reorder floating point operations.
Thanks,
Nadav
On Apr 3, 2013, at 10:29 AM, "Nowicki, Tyler" <tyler.nowicki at intel.com> wrote:
> Hi,
>
> I have a question about LoopVectorize. I wrote a simple test case, a dot product loop and found that packed instructions are generated when input arrays are integer, but not when they are float or double.
>
> If I modify the float example in http://llvm.org/docs/Vectorizers.html by adding restrict to the input arrays packed instructions are generated. Although it should not be required I tried doing the same to the input arrays of my dot product example but it still doesn’t generate packed float or double instructions.
>
> Is the loop vectorizer supposed to generate packed float and double instructions? Is this a bug, or am I doing something wrong?
>
> Tyler
>
> float dotproduct(float *A, float *B, int n) {
> float sum = 0;
> for(int i = 0; i < n; ++i) {
> sum += A[i] * B[i];
> }
> return sum;
> }
>
> clang dotproduct.cpp -O3 -fvectorize -march=atom -S -o -
>
> <loop body>
> .LBB1_1:
> movss (%rdi), %xmm1
> addq $4, %rdi
> mulss (%rsi), %xmm1
> addq $4, %rsi
> decl %edx
> addss %xmm1, %xmm0
> jne .LBB1_1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130403/13b053c5/attachment.html>
More information about the llvm-dev
mailing list