[LLVMdev] Packed instructions generaetd by LoopVectorize?

Nowicki, Tyler tyler.nowicki at intel.com
Thu Apr 4 16:12:31 PDT 2013


Thanks, that did it!

Are there any plans to enable the loop vectorizer by default?

From: Nadav Rotem [mailto:nrotem at apple.com]
Sent: Wednesday, April 03, 2013 13:33 PM
To: Nowicki, Tyler
Cc: LLVM Developers Mailing List
Subject: Re: Packed instructions generaetd by LoopVectorize?

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<mailto: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/20130404/25c661a3/attachment.html>


More information about the llvm-dev mailing list