<html><body><div style="color:#000; background-color:#fff; font-family:arial, helvetica, sans-serif;font-size:12pt"><div><span>Let me describe more precisely what I am doing and why the results I got may help improve LLVM's performance on modern x86-64 processors regardless of the front end (GCC, Clang or DragonEgg).<br></span></div><div><span><br></span></div><div><span>I am running ALL my tests on an Intel Xeon E5540 processor, which is an x86-64 Nehalem processor. The OS is a 64-bit version of Ubuntu. So, I am running all my tests on the same x86-64 machine and am only experimenting with compiler options. What I meant by running in x86-32 mode is simply using the -m32 option (passed through the llvm-gcc front end, but I believe the front end is irrelevant with regard to this matter, any confirmation?). The original reason for using this option was forcing the back end to work with a smaller number of physical registers to study register pressure
 reduction under more stringent constraints (as part of an academic research project). However, the observation that I am trying to communicate in this posting may not be related to register pressure. <br></span></div><div><span><br></span></div><div><span>The observation is that using the -march=core2 and -mtune=core2 options makes a significant positive difference in x86-32 mode (that is, with the -m32 option), while it does not make any significant difference in the x86-64 mode (without the -m32 option). My hypothesis is that the LLVM back end is making some good target-specific optimizations when the -m32 option is used but those good optimizations are disabled when this option is not used. This implies that enabling those optimizations in the native x86-64 mode may lead to a significant performance improvement. Here are the SPEC CPU2006 geometric-mean scores that I am measuring:</span></div><div><br><span></span></div><div><span>Native x86-64 mode
 (without the -m32 option):</span></div>
<span>Using -O3 only:                                               INT score: 19.24     FP score: 15.64<br>
  </span>

<div><span>Using -O3 -march=core2 -mtune=core2:     INT score: 19.16     FP score: 15.57<br>
  </span></div>

<div>So, there is no significant difference in this case. The small difference may just be random variation.<br>
</div>
<div><br>
</div>
<div><span>x86-32 mode (adding the -m32 option):</span></div>
<span>Using -O3 -m32 only:                                               INT score: 16.86     FP score: 14.09<br>
  </span>

<div><span>Using -O3 -m32 -march=core2 -mtune=core2:     INT score: 17.02     FP score: 15.24<br>
  </span></div>

<div>So, there is a significant difference in this case. In fact, the 8% geometric-mean improvement on FP2006 is a huge improvement that comes out of many double-digit percentage improvements on some individual benchmarks. The biggest improvement is 48% on gromacs, which is a CPU-intensive FP benchmark. <br>
</div>
<div><br></div><div>The above geometric means are consistent with the logical expectation that LLVM's performance in the native x86-64 mode is better, because more spill code is generated when the -m32 option is used. However, these aggregate numbers hide the fact that LLVM generates much faster code for some benchmarks when the -m32 option is used. An extreme example is the bwaves benchmark, which has a score of 15.5 in the native mode and a score of 23 (a 48% speedup) when the -m32 option is used. If LLVM is capable of achieving the higher score in the -m32 mode, it should be able to achieve at least the same score in the native mode. So, the question is: are there any good optimizations that we are losing in the native x86-64 mode? If yes, can we enable them to get better performance on x86-64?</div><div><br></div><div>It seems to me that the back end is somehow assuming that modern x86-64 machines magically solve all the scheduling and tuning
 problems and do not need any help from the compiler. Any truth to this?<br></div><div><br></div><div>Can anyone who is interested in performance on x86-64 try rerunning his/her tests using the -m32 mode to see if that gives any speedup? <br></div><div><br></div><div>Many thanks!<br></div><div>-Ghassan<br>
</div>
<div><br></div><div><br></div>  <div style="font-family: arial,helvetica,sans-serif; font-size: 12pt;"> <div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"> <div dir="ltr"> <font face="Arial" size="2"> <hr size="1">  <b><span style="font-weight: bold;">From:</span></b> Gordon Keiser <gkeiser@arxan.com><br> <b><span style="font-weight: bold;">To:</span></b> Ghassan Shobaki <ghassan_shobaki@yahoo.com>; "llvmdev@cs.uiuc.edu" <llvmdev@cs.uiuc.edu> <br> <b><span style="font-weight: bold;">Sent:</span></b> Monday, January 16, 2012 2:34 AM<br> <b><span style="font-weight: bold;">Subject:</span></b> RE: [LLVMdev] -march and -mtune options on x86<br> </font> </div> <br>
<div id="yiv1980890920"><style><!--
#yiv1980890920  
 _filtered #yiv1980890920 {font-family:"Cambria Math";panose-1:2 4 5 3 5 4 6 3 2 4;}
 _filtered #yiv1980890920 {font-family:Calibri;panose-1:2 15 5 2 2 2 4 3 2 4;}
 _filtered #yiv1980890920 {font-family:Tahoma;panose-1:2 11 6 4 3 5 4 4 2 4;}
#yiv1980890920  
#yiv1980890920 p.yiv1980890920MsoNormal, #yiv1980890920 li.yiv1980890920MsoNormal, #yiv1980890920 div.yiv1980890920MsoNormal
        {margin:0in;margin-bottom:.0001pt;font-size:12.0pt;font-family:"serif";}
#yiv1980890920 a:link, #yiv1980890920 span.yiv1980890920MsoHyperlink
        {color:blue;text-decoration:underline;}
#yiv1980890920 a:visited, #yiv1980890920 span.yiv1980890920MsoHyperlinkFollowed
        {color:purple;text-decoration:underline;}
#yiv1980890920 span.yiv1980890920EmailStyle17
        {font-family:"sans-serif";color:#1F497D;}
#yiv1980890920 .yiv1980890920MsoChpDefault
        {font-size:10.0pt;}
 _filtered #yiv1980890920 {margin:1.0in 1.0in 1.0in 1.0in;}
#yiv1980890920 div.yiv1980890920WordSection1
        {}
--></style><div><div class="yiv1980890920WordSection1"><div class="yiv1980890920MsoNormal"><span style="font-size: 11pt; font-family: "sans-serif"; color: rgb(31, 73, 125);">Which options are you seeing that cause the largest difference, and on which targets?   As Chandler mentioned there has been a large amount of variation in x86 targets, and there are certain optimizations that can be done, on say a Pentium (scheduling instructions which are pairable and non-dependent so the U and V pipelines are saturated without contention, for example) that don’t make sense to take the time with on a true i386 target.  Likewise there were certain optimizations on the i386 such as decomposing multiplications into left shifts which generally wouldn’t be needed on a modern processor.   x64 hasn’t seen nearly the same amount of variation since it came into existence.  </span></div><div class="yiv1980890920MsoNormal"><span
 style="font-size: 11pt; font-family: "sans-serif"; color: rgb(31, 73, 125);">  </span></div><div class="yiv1980890920MsoNormal"><span style="font-size: 11pt; font-family: "sans-serif"; color: rgb(31, 73, 125);">-Gordon</span></div><div class="yiv1980890920MsoNormal"><a rel="nofollow" name="_MailEndCompose"><span style="font-size: 11pt; font-family: "sans-serif"; color: rgb(31, 73, 125);">  </span></a></div><div><div style="border-right: medium none; border-width: 1pt medium medium; border-style: solid none none; border-color: rgb(181, 196, 223) -moz-use-text-color -moz-use-text-color; padding: 3pt 0in 0in;"><div class="yiv1980890920MsoNormal"><b><span style="font-size: 10pt; font-family: "sans-serif";">From:</span></b><span style="font-size: 10pt; font-family: "sans-serif";"> llvmdev-bounces@cs.uiuc.edu [mailto:llvmdev-bounces@cs.uiuc.edu] <b>On Behalf Of </b>Ghassan Shobaki<br><b>Sent:</b>
 Sunday, January 15, 2012 2:55 AM<br><b>To:</b> llvmdev@cs.uiuc.edu<br><b>Subject:</b> [LLVMdev] -march and -mtune options on x86</span></div></div></div><div class="yiv1980890920MsoNormal">  </div><div><div><div class="yiv1980890920MsoNormal" style="background: none repeat scroll 0% 0% white;"><span style="font-family: "sans-serif"; color: black;">I have been doing some benchmarking on x86 using llvm 2.9 with the llvm-gcc 4.2 front end. I noticed that the -march and -mtune options make a significant positive difference in x86-32 mode but hardly make any difference in x86-64 mode. The small difference that I am measuring when the target is x86-64 could easily be random variation, while for the x86-32 target I am measuring a huge difference on some benchmarks. Does anyone have an explanation for this? Does the llvm back end somehow ignore these options when the target is x86-64?</span></div></div><div><div class="yiv1980890920MsoNormal"
 style="background: none repeat scroll 0% 0% white;"><span style="font-family: "sans-serif"; color: black;">  </span></div></div><div><div class="yiv1980890920MsoNormal" style="background: none repeat scroll 0% 0% white;"><span style="font-family: "sans-serif"; color: black;">Thank you in advance!</span></div></div><div><div class="yiv1980890920MsoNormal" style="background: none repeat scroll 0% 0% white;"><span style="font-family: "sans-serif"; color: black;">-Ghassan</span></div></div><div><div class="yiv1980890920MsoNormal" style="background: none repeat scroll 0% 0% white;"><span style="font-family: "sans-serif"; color: black;">  </span></div></div></div></div></div></div><br><br> </div> </div>  </div></body></html>