Shen Liu via llvm-dev
2017-Oct-22 18:32 UTC
[llvm-dev] Replace "while" "for" loops with "If-Else"
Hi weiren, Thanks for your suggestion! Yes, I am trying to do this "nested flattening". It seems that I need a post-dominator tree-based algorithm to flatten the nested loops from the innermost to the outermost, level by level. Is there any feature already existed in LLVM tools? Or similar? On Sun, Oct 22, 2017 at 2:31 AM, 陳韋任 <chenwj.cs97g at g2.nctu.edu.tw> wrote:> If the inner loop can be flatten [1] (not sure if I use the right word), > which means transforming the nested loop into 1-level loop, I think you can > continue using your pass on it. > > [1] https://stackoverflow.com/questions/18369260/flattening- > a-very-nested-loop > > HTH, > chenwj > > > 2017-10-22 13:51 GMT+08:00 Shen Liu via llvm-dev <llvm-dev at lists.llvm.org> > : > >> Hi everyone, >> >> I hope to implement a feature to transform an IR with "while" or "for" >> loops to a new IR with no loop. Instead, I just want to use if-else >> statements in the new IR to implement the original semantics. >> >> I can easily write a transform pass to handle the 1-level loop case, but >> for nested loops it seems a little harder. >> >> Can you show me some hints? Thank you very much! >> >> Best regards, >> >> Shen >> >> _______________________________________________ >> LLVM Developers mailing list >> llvm-dev at lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >> >> > > > -- > Wei-Ren Chen (陳韋任) > Homepage: https://people.cs.nctu.edu.tw/~chenwj >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20171022/f84d16f3/attachment.html>
陳韋任 via llvm-dev
2017-Oct-23 13:02 UTC
[llvm-dev] Replace "while" "for" loops with "If-Else"
You can give Polly [1] a shot. I'm not aware of existing pass does similar work. [1] http://polly.llvm.org/ 2017-10-23 2:32 GMT+08:00 Shen Liu <sxl463 at gmail.com>:> Hi weiren, > > Thanks for your suggestion! Yes, I am trying to do this "nested > flattening". It seems that I need a post-dominator tree-based algorithm to > flatten the nested loops from the innermost to the outermost, level by > level. > > Is there any feature already existed in LLVM tools? Or similar? > > > > On Sun, Oct 22, 2017 at 2:31 AM, 陳韋任 <chenwj.cs97g at g2.nctu.edu.tw> wrote: > >> If the inner loop can be flatten [1] (not sure if I use the right word), >> which means transforming the nested loop into 1-level loop, I think you can >> continue using your pass on it. >> >> [1] https://stackoverflow.com/questions/18369260/flattening- >> a-very-nested-loop >> >> HTH, >> chenwj >> >> >> 2017-10-22 13:51 GMT+08:00 Shen Liu via llvm-dev <llvm-dev at lists.llvm.org >> >: >> >>> Hi everyone, >>> >>> I hope to implement a feature to transform an IR with "while" or "for" >>> loops to a new IR with no loop. Instead, I just want to use if-else >>> statements in the new IR to implement the original semantics. >>> >>> I can easily write a transform pass to handle the 1-level loop case, but >>> for nested loops it seems a little harder. >>> >>> Can you show me some hints? Thank you very much! >>> >>> Best regards, >>> >>> Shen >>> >>> _______________________________________________ >>> LLVM Developers mailing list >>> llvm-dev at lists.llvm.org >>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >>> >>> >> >> >> -- >> Wei-Ren Chen (陳韋任) >> Homepage: https://people.cs.nctu.edu.tw/~chenwj >> > >-- Wei-Ren Chen (陳韋任) Homepage: https://people.cs.nctu.edu.tw/~chenwj -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20171023/12a371dc/attachment.html>
Michael Kruse via llvm-dev
2017-Oct-23 13:11 UTC
[llvm-dev] Replace "while" "for" loops with "If-Else"
I am not sure I understand the problem statement. If the max iteration count is statically known, any loop nest can be unrolled. Otherwise, I don't see how one can remove such loops. Recursion maybe? Polly does not implement loop flattening. That is, there's a "flatten schedule" pass which would theoretically do this (if loop iteration count is known), but it is not meant for production use. Michael 2017-10-23 15:02 GMT+02:00 陳韋任 via llvm-dev <llvm-dev at lists.llvm.org>:> You can give Polly [1] a shot. I'm not aware of existing pass does similar > work. > > [1] http://polly.llvm.org/ > > 2017-10-23 2:32 GMT+08:00 Shen Liu <sxl463 at gmail.com>: >> >> Hi weiren, >> >> Thanks for your suggestion! Yes, I am trying to do this "nested >> flattening". It seems that I need a post-dominator tree-based algorithm to >> flatten the nested loops from the innermost to the outermost, level by >> level. >> >> Is there any feature already existed in LLVM tools? Or similar? >> >> >> >> On Sun, Oct 22, 2017 at 2:31 AM, 陳韋任 <chenwj.cs97g at g2.nctu.edu.tw> wrote: >>> >>> If the inner loop can be flatten [1] (not sure if I use the right word), >>> which means transforming the nested loop into 1-level loop, I think you can >>> continue using your pass on it. >>> >>> [1] >>> https://stackoverflow.com/questions/18369260/flattening-a-very-nested-loop >>> >>> HTH, >>> chenwj >>> >>> >>> 2017-10-22 13:51 GMT+08:00 Shen Liu via llvm-dev >>> <llvm-dev at lists.llvm.org>: >>>> >>>> Hi everyone, >>>> >>>> I hope to implement a feature to transform an IR with "while" or "for" >>>> loops to a new IR with no loop. Instead, I just want to use if-else >>>> statements in the new IR to implement the original semantics. >>>> >>>> I can easily write a transform pass to handle the 1-level loop case, but >>>> for nested loops it seems a little harder. >>>> >>>> Can you show me some hints? Thank you very much! >>>> >>>> Best regards, >>>> >>>> Shen >>>> >>>> _______________________________________________ >>>> LLVM Developers mailing list >>>> llvm-dev at lists.llvm.org >>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >>>> >>> >>> >>> >>> -- >>> Wei-Ren Chen (陳韋任) >>> Homepage: https://people.cs.nctu.edu.tw/~chenwj >> >> > > > > -- > Wei-Ren Chen (陳韋任) > Homepage: https://people.cs.nctu.edu.tw/~chenwj > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >