[LLVMdev] Packed instructions generaetd by LoopVectorize?

Nowicki, Tyler tyler.nowicki at intel.com
Wed Apr 3 10:29:48 PDT 2013


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?


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>
        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/529c8ae3/attachment.html>

More information about the llvm-dev mailing list