<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
</style>
</head>
<body class='hmmessage'>
> Date: Mon, 2 Mar 2009 13:41:45 -0800<br>> From: eli.friedman@gmail.com<br>> To: llvmdev@cs.uiuc.edu<br>> Subject: Re: [LLVMdev] Tight overlapping loops and performance<br>><br>> Hmm, on my computer, I get around 2.5 seconds with both gcc -O3 and<br>> llvm-gcc -O3 (using llvm-gcc from svn).  Not sure what you're doing<br>> differently; I wouldn't be surprised if it's sensitive to the version<br>> of LLVM.<br><br>For which version of gcc?  I should mention I'm on OS X and using the LLVM SVN.<br> <br>> First, try looking at the generated code... the code LLVM generates is<br>> probably not what you're expecting.  I'm getting the following for the<br>> main loop:<br><br>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.<br> <br>> int timeout = 2000;<br>> int loopcond;<br>> do {<br>> timeoutwork();<br>> do {<br>> timeout--;<br>> loopcond = computationresult();<br>> } while (loopcond && timeout);<br>> } while (loopcond);<br><br>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.  <br><br><br>Jonathan<br><br /><hr />Windows Live™ Contacts: Organize your contact list.  <a href='http://windowslive.com/connect/post/marcusatmicrosoft.spaces.live.com-Blog-cns!503D1D86EBB2B53C!2285.entry?ocid=TXT_TAGLM_WL_UGC_Contacts_032009' target='_new'>Check it out.</a></body>
</html>