[LLVMdev] Enabling vectorization with LLVM 3.3 for a DSL emitting LLVM IR
letz at grame.fr
Fri Jul 5 07:50:16 PDT 2013
Le 5 juil. 2013 à 04:11, Tobias Grosser <tobias at grosser.es> a écrit :
> On 07/04/2013 01:39 PM, Stéphane Letz wrote:
>> Our DSL can generate C or directly generate LLVM IR. With LLVM 3.3, we can vectorize the C produced code using clang with -O3, or clang with -O1 then opt -O3 -vectorize-loops. But the same program generating LLVM IR version cannot be vectorized with opt -O3 -vectorize-loops. So our guess is that our generated LLVM IR lacks some informations that are needed by the vectorization passes to correctly work.
>> Any idea of what could be lacking?
> Without any knowledge about the code guessing is hard. You may miss the 'noalias' keyword or nsw/nuw flags, but there are many possibilities.
> If you add '-debug' to opt you may get some hints. Also, if you have a small test case, posting the LLVM-IR may help.
I did some progress:
1) adding a DataLayout in my generated LLVM Module, explicitly as a string. BTW is there any notion of "default" DataLayout that could be used? How is a LLVM Module supposed to know which DataLayout to use (in general) ?
2) next the resulting module could not be vectorized with "opt -O3 -vectorize-loops -debug -S m1.ll -o m2.ll", but if I do in "two steps" like:
opt -O3 -vectorize-loops -debug S m1.ll -o m2.ll
opt -O3 -vectorize-loops -debug S m2.ll -o m3.ll
then it works….
More information about the llvm-dev