[llvm-commits] [llvm] r42075 - in /llvm/trunk: lib/Transforms/Scalar/LICM.cpp test/Transforms/LICM/2007-09-17-PrompteValue.ll

Devang Patel dpatel at apple.com
Wed Sep 19 10:49:51 PDT 2007


On Sep 19, 2007, at 9:49 AM, Dan Gohman wrote:

>> Exactly, that's what I meant to say when I said "when loop
>> conditionals are runtime dependent". To ensure safety in
>> PromoteValuesInLoop(), one needs to prove that basic-block is  
>> executed
>> at least once. The question is how ?
>
> The most general way to do this is to convert loops like this:
>
>  while (x) {
>    body;
>  }
>
> to this:
>
>  if (x) {
>    do {
>      body;
>    } while (x);
>  }
>
> In the second form, code hoisted/sunk/promoted out of the loop will
> still be under the guard of the if. Also see tree-ssa-loop-ch.c in  
> GCC,
> for example.

In llvm, loop-rotation pass does this. However, what if LICM input is  
not processed by loop rotation pass ? One conservative approach is to  
check whether StoreInst and LoadInst in question dominates loop  
exit(s) or not. I'll try it and see if it affects performance for  
nightly tester benchmarks or not.

-
Devang



More information about the llvm-commits mailing list