[LLVMdev] compounding loop exit conditions

Andrew Trick atrick at apple.com
Wed Jan 11 15:46:58 PST 2012


On Dec 27, 2011, at 6:16 AM, Hanfeng Qin wrote:

> volatile int a;
> int b,e ;
> ....
> 
> void *f1 (void *notused)
> {
>     int *c;
>     int d;
> 
>     while (1) {
>         c = &a;
>         if (*c != 0 ) d = 1;
>         if ( d != 1 && e != 0 && e != d ) break;
>         if ( *c == e) break;
>     }
>     b = 1;
> }
> 
> In the BB flow chart, B15 and B20 is the exiting block recognized by LLVM. But One of the loop exit conditions is a combination of the compounded branches located in B15, B12 and B9. 
> 
> Can any suggestion be shared with me to solve this problem?

I didn't see a response to this, but clearly you're asking for control dependence information within the loop. You'll have to look for CFG predecessors of the exiting block that are not deeper in the postdominator tree. For a fully qualified loop exiting condition, you have to do this iteratively as you walk down the postdominator tree. Eventually you'll hit a leaf in the tree or the loop header. I'm sure you can find a paper on control dependence.

-Andy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120111/a42674f5/attachment.html>


More information about the llvm-dev mailing list