[LLVMdev] Tight overlapping loops and performance

Jonathan Turner probata at hotmail.com
Mon Mar 2 14:45:10 PST 2009


> Date: Mon, 2 Mar 2009 13:41:45 -0800
> From: eli.friedman at gmail.com
> To: llvmdev at cs.uiuc.edu
> Subject: Re: [LLVMdev] Tight overlapping loops and performance
>
> Hmm, on my computer, I get around 2.5 seconds with both gcc -O3 and
> llvm-gcc -O3 (using llvm-gcc from svn).  Not sure what you're doing
> differently; I wouldn't be surprised if it's sensitive to the version
> of LLVM.

For which version of gcc?  I should mention I'm on OS X and using the LLVM SVN.
 
> First, try looking at the generated code... the code LLVM generates is
> probably not what you're expecting.  I'm getting the following for the
> main loop:

I was seeing the same thing, but wasn't sure what to make of it.  It looks like values are being swapped into and out of memory and not holding them in registers.  That's why I was asking about other optimization passes, at first glance -mem2reg looked like a good candidate, but I didn't notice any improvement using it blindly.
 
> int timeout = 2000;
> int loopcond;
> do {
> timeoutwork();
> do {
> timeout--;
> loopcond = computationresult();
> } while (loopcond && timeout);
> } while (loopcond);

My current implementation uses something very similar, but if you'll notice the difference between this example and my examples is that the branch for checking 'timeout' is taken in the majority case where in mine it isn't.  It can be checked separately for less cost, assuming the variables stay in registers.  


Jonathan

_________________________________________________________________
Windows Liveā„¢ Contacts: Organize your contact list. 
http://windowslive.com/connect/post/marcusatmicrosoft.spaces.live.com-Blog-cns!503D1D86EBB2B53C!2285.entry?ocid=TXT_TAGLM_WL_UGC_Contacts_032009
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090302/b0b3d67c/attachment.html>


More information about the llvm-dev mailing list