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?
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."));
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.