[LLVMdev] Loop Unroll a constant number of times?

Chad Rosier mcrosier at apple.com
Tue Jan 31 17:30:56 PST 2012


Ryan,
I see the following command line options in LoopUnrollPass.cpp:

static cl::opt<unsigned>
UnrollThreshold("unroll-threshold", cl::init(150), cl::Hidden,
  cl::desc("The cut-off point for automatic loop unrolling"));

static cl::opt<unsigned>
UnrollCount("unroll-count", cl::init(0), cl::Hidden,
  cl::desc("Use this unroll count for all loops, for testing purposes"));

static cl::opt<bool>
UnrollAllowPartial("unroll-allow-partial", cl::init(false), cl::Hidden,
  cl::desc("Allows loops to be partially unrolled until "
           "-unroll-threshold loop size is reached."));

static cl::opt<bool>
UnrollRuntime("unroll-runtime", cl::ZeroOrMore, cl::init(false), cl::Hidden,
  cl::desc("Unroll loops with run-time trip counts"));

I assume the first two are most applicable to what you're trying to do.  I've never used these options, so it would be a good idea to look at the source to see what these are really doing.

Also, you'll probably need to put -mllvm before the argument to pass it to the backend (clang -mllvm -unroll-threshold=10).

You can also use the -debug-only=loop-unroll option to get debug information.  It too requires the -mllvm option.

Hope this helps,
  Chad


On Jan 31, 2012, at 5:16 PM, Ryan Taylor <ryta1203 at gmail.com> wrote:

> Is it possible to unroll a loop (forcibly if necessary) with llvm (possibly the -loop-unroll pass) a constant number of times. 
> 
> I believe that I read that the -unroll-count=x option was removed, correct? So is there some other way to do this or is this just not possible in llvm?
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list