<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=iso-8859-1"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:36.0pt;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:408380491;
        mso-list-type:hybrid;
        mso-list-template-ids:1923622126 -1886610678 134807555 134807557 134807553 134807555 134807557 134807553 134807555 134807557;}
@list l0:level1
        {mso-level-start-at:0;
        mso-level-number-format:bullet;
        mso-level-text:\F0D8;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Wingdings;
        mso-fareast-font-family:Calibri;
        mso-bidi-font-family:"Times New Roman";
        color:#1F497D;}
ol
        {margin-bottom:0cm;}
ul
        {margin-bottom:0cm;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-GB link=blue vlink=purple><div class=WordSection1><div><p class=MsoNormal>On 5 June 2013 11:59, David Tweed <<a href="mailto:david.tweed@arm.com" target="_blank">david.tweed@arm.com</a>> wrote:<o:p></o:p></p><div><div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm'><div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>(I've very rarely had O3 optimzation, rather than some program specific subset of the options, acheive any non-noise-level speed-up over O2  with gcc/g++.)</span><o:p></o:p></p></div></div></blockquote><div><p class=MsoNormal><span style='color:#1F497D'>[snip]</span><o:p></o:p></p></div><div><p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span style='font-family:Wingdings;color:#1F497D'><span style='mso-list:Ignore'>Ø<span style='font:7.0pt "Times New Roman"'>  </span></span></span><![endif]>"We find that, while -O2 has a significant impact relative to -O1, the performance impact of -O3 over -O2 optimizations is indistinguishable from random noise."<o:p></o:p></p></div><div><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>That's something I remember well, but there's an obvious question lurking in there: is this because the transformations that apply at O3, while they count as "aggressive", not actually ever transforms to faster code or are they things which are capable of optimizing when used in the right places _but we don't do well at deciding where that is_? I don't have any actual evidence, but I'm inclined towards thinking it's more likely to be the second (and occasionally having looked at gcc assembly it can be seen to have done things like loop unrolling in the most unlikely to be profitable places). So to simplify a lot the difference between O2 and O3 (at least on gcc) might well be the difference between "guaranteed wins only" and "add some transforms that we don't predict the optimization effects of well". At least from some mailing lists I've read other people share that view of the optimization flags in practice, not aggressiveness or stability. Maybe they shouldn't have this "interpretation" in LLVM/clang; I'm just pointing out what some people might expect from previous experience.<o:p></o:p></span></p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm'><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Under that view, if the LLVM vectorizer was well enough understood I would think it would be good to include at O2. However, I suspect that the effects from having effectively two versions of each loop around are probably conflicting enough that it's a better decision to make O3 be the level at which it is blanket enabled.</span><o:p></o:p></p></div></blockquote></div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span style='font-family:Wingdings;color:#1F497D'><span style='mso-list:Ignore'>Ø<span style='font:7.0pt "Times New Roman"'>  </span></span></span><![endif]>My view of O3 is that it *only* regards how aggressive you want to optimize your code. Some special cases are proven to run faster on O3, mostly benchmarks improvements that feed compiler engineers, and on those grounds, O3 can be noticeable if you're allowed to be more aggressive than usual. This is why I mentioned FP-safety, undefined behaviour, vectorization, etc.<o:p></o:p></p></div><div><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Again, I can see this as a logical position, I've just never actually encountered differences in FP-safety or undefined behaviour between O2 and O3. Likewise I haven't really seen any instability or undefined behaviour from the vectorizer. (Sorry if I'm sounding a bit pendantic; I've been doing a lot of performance testing/exploration recently so I've been knee deep in the difference between "I'm sure it must be the case that..." expectations and what experimentation reveals is actually happening.)<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p></div><div><p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span style='font-family:Wingdings;color:#1F497D'><span style='mso-list:Ignore'>Ø<span style='font:7.0pt "Times New Roman"'>  </span></span></span><![endif]>I don't expect O3 results to be faster than O2 results on average, but on specific cases where you know that the potential disaster is acceptable, should be fine to assume O3. Most people, though, use O3 (or O9!) in the expectancy that this will be always better. It not being worse than O2 doesn't help, either. ;)<o:p></o:p></p></div><div><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Again, my experience is that I haven't seen any "semantic" disasters from O3, just that it mostly it doesn't help much, sometimes speeds execution up relative to O2, sometimes slows execution down relative to O2 and certainly increases compile time. It sounds like you've had a wilder ride than me and seen more cases where O3 has actually changed observable behaviour.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p></div><div><p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span style='font-family:Wingdings;color:#1F497D'><span style='mso-list:Ignore'>Ø<span style='font:7.0pt "Times New Roman"'>  </span></span></span><![endif]>I don't think it's *wrong* to put aut-vec on O2, I just think it's not its place to be, that's all. The potential to change results are there.<o:p></o:p></p></div><div><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>This is what I'd like to know about: what specific potential to change results have you seen in the vectorizer?<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Cheers,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Dave<o:p></o:p></span></p></div></div></div></body></html>