[cfe-dev] vectorization for X86

Régis Portalez via cfe-dev cfe-dev at lists.llvm.org
Wed Mar 16 16:08:02 PDT 2016


Hi. I don't know how llvm works internally, but I guess the code you wrote don't need any vectorization.
It's probably because its completely memory bound and hardware prefetch will do the job for you. 
You can force vectorization using some pragmas (I don't remember which). 
Regis
Altimesh

-----Message d'origine-----
De : "Rail Shafigulin via cfe-dev" <cfe-dev at lists.llvm.org>
Envoyé : ‎16/‎03/‎2016 23:00
À : "llvm-dev" <llvm-dev at lists.llvm.org>; "cfe-dev at lists.llvm.org" <cfe-dev at lists.llvm.org>
Objet : [cfe-dev] vectorization for X86

I'm trying to vectorize a simple C code. My problem is that I don't quite understand the relationship between clang --target option and the cores mentioned in X86.td as well as other X86 related options (such as -mtune). Below are the command and the code that I'm trying to vectorize. The code compiles but I don't see any vectors. What am I doing wrong? Any help is appreciated.


clang -S x.c --target=x86_64-pc-gnu -mtune=core-avx2 -o x.x86.s -fvectorize -fno-lax-vector-conversions -fslp-vectorize-aggressive -fslp-vectorize



#define N 32


int main () {


  int  a[N], b[N];
  int c[N];


  for (int i = 0; i < N; ++i)
       c[i] = a[i] + b[i];


  int sum=0;
  for (int i = 0; i < N; ++i)
       sum += c[i];


  return sum;
}






-- 

Rail Shafigulin

Software Engineer 
Esencia Technologies
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160317/155a3791/attachment.html>


More information about the cfe-dev mailing list