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?
I see the following command line options in LoopUnrollPass.cpp:
UnrollThreshold("unroll-threshold", cl::init(150), cl::Hidden,
cl::desc("The cut-off point for automatic loop unrolling"));
UnrollCount("unroll-count", cl::init(0), cl::Hidden,
cl::desc("Use this unroll count for all loops, for testing purposes"));
UnrollAllowPartial("unroll-allow-partial", cl::init(false), cl::Hidden,
cl::desc("Allows loops to be partially unrolled until "
"-unroll-threshold loop size is reached."));
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,
See clang -mllvm -help-hidden. If that doesn't work, llc -help-hidden.
Probably want something like -mllvm -unroll-runtime -mllvm -unroll-count=N.
As with any experimental options, look at the source, and -mllvm -debug-only=loop-unroll output to understand what it's doing.
Thanks. Unfortunately, the runtime won’t really work for what I’m doing but it seems that I can statically unroll just fine for the most part.