[LLVMdev] State of Loop Unrolling and Vectorization in LLVM

Murali, Sriram sriram.murali at intel.com
Mon Apr 15 08:22:24 PDT 2013


Hi , I have a test case (and a micro benchmark made out of the test case) to check if loop unrolling and loop vectorization is efficiently done on LLVM. Here is the test case (credits: Tyler Nowicki)
{code}
extern float * array;
extern int array_size;

float g()
{
  int i;
  float total = 0;

  for(i = 0; i < array_size; i++)
  {
    total += array[i];
  }

  return total;
}

{code}

When compiled with the options -m32 -mfpmath=sse -ffast-math -funroll-loops -O3 -march=atom for gcc, and clang, I am not able to see the loop being unrolled / vectorized. The microbenchmark which runs the function g() over a billion times shows quite some performance difference on gcc against clang
Gcc - 8.6 seconds
Clang - 12.7 seconds

Evidently, the addition operation can be vectorized to  use addps, (clang does addss), and the loop can be unrolled for better performance. Any idea why this is happening ?

Thanks
Sriram

--
Sriram Murali
SSG/DPD/ECDL/DMP
+1 (519) 772 - 2579

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130415/ff0af6dc/attachment.html>


More information about the llvm-dev mailing list