Hi Chris, Is there a compelling reason why llvm-gcc does not always produce natural loops. Is it a code size issue, or are there performance implications as well? I am seeing a simple 'while' loop compiled to an unnatural loop, without any gotos, breaks, or continues. What is the reason for this? Marc On Wed, Feb 11, 2009 at 6:51 PM, Chris Lattner <clattner at apple.com> wrote:> > On Feb 11, 2009, at 1:13 PM, Marc de Kruijf wrote: > > > I am reviving this thread because I am seeing the same thing > > (unnatural loops produced by llvm-gcc), but it is not limited to -O0 > > -- I am seeing it for -O2 and -O3 as well. > > Some of my research work is relying on LoopInfo to provide loop > > information for all loops, but it is missing these loops. Is there > > any work in the pipeline that aims to fix this? > > Not that I know of. There has been a project on the open projects > list to write a pass that converts all loops to natural loops (through > code duplication). That would be a nice and self-contained project if > anyone is interested. > > -Chris > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090212/6364bba2/attachment.html>
Hi Marc,> Is there a compelling reason why llvm-gcc does not always produce natural > loops. Is it a code size issue, or are there performance implications as > well? I am seeing a simple 'while' loop compiled to an unnatural loop, > without any gotos, breaks, or continues. What is the reason for this?is it already an unnatural loop when it comes out of the gcc parts of llvm-gcc (you can check this by compiling with: -O0 -emit-llvm)? Or is it llvm itself that creates the unnatural loops? Ciao, Duncan.
On Feb 12, 2009, at 7:55 AM, Duncan Sands wrote:> Hi Marc, > >> Is there a compelling reason why llvm-gcc does not always produce >> natural >> loops. Is it a code size issue, or are there performance >> implications as >> well? I am seeing a simple 'while' loop compiled to an unnatural >> loop, >> without any gotos, breaks, or continues. What is the reason for >> this? > > is it already an unnatural loop when it comes out of the gcc parts of > llvm-gcc (you can check this by compiling with: -O0 -emit-llvm)? Or > is it llvm itself that creates the unnatural loops?Right. There is little we can do about the -O0 -emit-llvm code: this is a literal translation of what the GCC front-end gives us. If some *optimizer* is turning reducible loops into non-reducible control flow, then that is a completely different matter and I would consider that to be a serious bug. If the gcc front-end is doing this to you, you can try out clang, which should not. -Chris