Hello, Wojtek. I owe much to you. Thank you. My HL code should be simple without any 'goto','break' and so on. Simple as just loops with 'for' and 'if's inside it, so your comment looks helpful. I'll try. Just one thing which concerning me is demotePHI() I couldn't find it in 1.9 so seems to me another installation of the newest version of LLVM. Anyway, Thank you. Truly yours, Seung ---- Original message ---->Date: Sun, 03 Feb 2008 20:54:24 +0100 >From: Wojciech Matyjewicz <wmatyjewicz at fastmail.fm> >Subject: Re: [LLVMdev] Question to Chris >To: LLVM Developers Mailing List <llvmdev at cs.uiuc.edu> > >Seung, > >> Would you please explain to me how I can access to this problem in a better way if you can figure out? > >Here are my thoughts on your first question: "how to make it count >correctly for the reconstruction of loops?". I believe it can't be done >for an arbitrary loop. However, IIRC from previous posts your loops are >simple - for example: they don't contain any breaks, gotos. I think, >your reconstruction could be done for two forms of loops that are very >common: > >1) rotated canonical loop (bb8.outer in your example): >The loop has only one backedge, and an induction variable counting from >0 with step 1. The only basic block that branches out of the loop (so >called, exiting block) is the backedge. > >header: > %i = phi [ 0, %preheader ], [ %i.next, %body ] > ... > br label %body ;%header and %body may be the same block > >body: > ... > %i.next = add %i, 1 > %c = seteq %i.next, %n > br %c, label %exit, label %header > >exit: > ... > >The loop iteration count is %n. In this case, it means that _every_ >basic block is executed %n times. Your current version of reconstruction >seems to be okay for loops in this form. > >2) unrotated canonical loop (bb8 in your example): >The loop has only one backedge and an induction variable counting from 0 >with step 1. The only basic block that branches out of the loop is the >loop header. > >header: > %i = phi [ 0, %preheader ], [ %i.next, %body ] > ... > %c = seteq %i, %n > br %c, label %exit, label %body > >body: > ... > %i.next = add %i, 1 > br label %header > >exit: > ... > >The loop iteration count is also %n. However, this time it means that >the loop header is executed %n times, while the rest of blocks - %n-1 >times. The reconstruction should take it into account. For example, it >could make a "for" loop from all loop basic blocks setting the iteration >count to %n-1, and then insert a copy of the loop header with %i==%n >after the "for". > >I also suggest taking look at the LoopInfo pass. It has many useful >methods to analyze loops. To determine the loop iteration count you may >use the ScalarEvolution pass as well. > >-Wojtek >_______________________________________________ >LLVM Developers mailing list >LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev