I am trying out the new loop vectorizer in LLVM 3.2. I wanted to see the effect of the pass in opt but I have no success. I used LLVM IR generated from C examples in http://blog.llvm.org/2012/12/new-loop-vectorizer.html#more and pass them to opt -S -O3 -vectorize-loops example.ll. However, I do not see vectorized output. What am I doing wrong?
I'm not entirely sure why this is the case, the target specific stuff for opt is still very new, but at the moment you have to explicitly set a triple for opt so it can access target-specific bits to estimate the cost of vectorization. Something like "opt -mtriple=x86_64-linux-gnu -S -O3 -vectorize-loops" should work. You can also specify a target cpu with -mcpu (which takes the same arguments as clang -march) to experiment with different SSE levels.
I think that this is a good opportunity to discuss this topic. At the moment ‘opt’ does not use the triple that is found in the module in order to initialize the backend and the backend related analysis passes. It relies on the ‘-mtriple’ command line flag. LLC on the other hand uses the host triple. I see the following options:
‘opt’ does not initialize the backend passes unless ‘-mtriple’ is used. (the current option)
‘opt’ grabs the triple from the bit code file and uses it to initialize the backend passes.
I'm not entirely sure why this is the case, the target specific stuff for
opt is still very new, but at the moment you have to explicitly set a
triple for opt so it can access target-specific bits to estimate the cost
of vectorization.
I think that this is a good opportunity to discuss this topic. At the
moment 'opt' does not use the triple that is found in the module in order
to initialize the backend and the backend related analysis passes. It
relies on the '-mtriple' command line flag. LLC on the other hand uses the
host triple. I see the following options:
1. 'opt' does not initialize the backend passes unless '-mtriple' is used.
(the current option)
2. 'opt' grabs the triple from the bit code file and uses it to initialize
the backend passes.
3. 'opt' gets the default target triple (like llc).
My only strong opinion is that I dislike #3.
I have a mild preference for encoding more in bitcode and less in
commandline switches, while still allowing commandline switches to override
what is in the bitcode.
From: "Nadav Rotem" <nrotem@apple.com>
To: "Benjamin Kramer" <benny.kra@gmail.com>
Cc: "llvmdev@cs.uiuc.edu List" <llvmdev@cs.uiuc.edu>
Sent: Monday, December 31, 2012 5:26:18 PM
Subject: Re: [LLVMdev] Trying out Loop Vectorizer
I'm not entirely sure why this is the case, the target specific stuff
for opt is still very new, but at the moment you have to explicitly
set a triple for opt so it can access target-specific bits to
estimate the cost of vectorization.
I think that this is a good opportunity to discuss this topic. At the
moment 'opt' does not use the triple that is found in the module in
order to initialize the backend and the backend related analysis
passes. It relies on the '-mtriple' command line flag. LLC on the
other hand uses the host triple. I see the following options:
1. 'opt' does not initialize the backend passes unless '-mtriple' is
used. (the current option)
2. 'opt' grabs the triple from the bit code file and uses it to
initialize the backend passes.
3. 'opt' gets the default target triple (like llc).
+1 on both points. Both opt and llc should work this way. To get llc’s current behavior, you should have to pass -mcpu=native or something, explicitly.