[LLVMdev] how to let loop induction variable count down
Burkhard Ilsen
bilsen at web.de
Fri Jun 17 13:16:20 PDT 2011
Hi all!
I am new to llvm, writing a backend.
The documentation for -indvars
(http://llvm.org/docs/Passes.html#indvars) says:
'Additionally, on targets where it is profitable, the loop could be
transformed to count down to zero (the "do loop" optimization). '
Does this mean that
void fn(void) {
volatile int temp;
int i;
for(i = 0; i != 100; ++i) {
temp = 99 - i;
}
}
can be optimized to
void fn(void) {
volatile int temp;
int i = 100;
while(--i >= 0) {
temp = i;
}
}
???
This "do loop" optimization would be profitable for my target, so how is
it performed?
Is there another pass available or an option for the command line?
Or do I have to write this pass by myself?
Thanks,
Burkhard
More information about the llvm-dev
mailing list