<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hi Gao, <div><br></div><div>Eli is right.  In many cases the OS is not compiled with AVX support but the application is. In other words, AVX code calling non-avx code is very common.  </div><div><br></div><div>Thanks,</div><div>Nadav</div><div><br><div><div>On Sep 20, 2013, at 2:58 PM, Gao, Yunzhong <<a href="mailto:yunzhong_gao@playstation.sony.com">yunzhong_gao@playstation.sony.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div lang="EN-US" link="blue" vlink="purple" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class="WordSection1" style="page: WordSection1;"><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;">Hi Eli,<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;">Thanks for the feedback. Please see below.<br>- Gao.<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;"> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;">From: Eli Friedman [<a href="mailto:eli.friedman@gmail.com" style="color: purple; text-decoration: underline;">mailto:eli.friedman@gmail.com</a>]<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;">Sent: Thursday, September 19, 2013 12:31 PM<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;">To: Gao, Yunzhong<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;">Cc:<span class="Apple-converted-space"> </span><a href="mailto:llvmdev@cs.uiuc.edu" style="color: purple; text-decoration: underline;">llvmdev@cs.uiuc.edu</a><o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;">Subject: Re: [LLVMdev] Proposal to improve vzeroupper optimization strategy<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;"> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;">> This is essentially equivalent to "don't insert vzeroupper anywhere", as<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;">> far as I can tell. (The case of SSE instructions without a v- prefixed<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;">> equivalent is rare enough we can separate it from this discussion.)<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;"> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;">So will you be interested in a patch that disables vzeroupper by default?<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;"> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;">I implemented this possibly over-engineering solution in our local tree to work<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;">around some bad instruction selection issues in LLVM backend. When benchmarking<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;">on our game codes, I noticed that sometimes legacy SSE instructions were<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;">selected despite existence of AVX equivalent, in which case the vzeroupper<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;">instruction was needed. And it is much easier to detect existence of vzeroupper<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;">instruction than to detect each single legacy SSE instructions.<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;"> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;">The instruction selection issues were later fixed in our tree (patches to be<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;">submitted later), at least for the handful of games I tested on. So a simple<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;">change to just disable vzeroupper by default will be acceptable to us as well.<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;"> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;">> The reason we need vzeroupper in the first place is because we can't assume<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;">> other functions won't use legacy SSE instructions; for example, on most<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;">> systems, calling sin() will use legacy SSE instructions.  I mean, if you can<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;">> make some unusual guarantee about your platform, it might make sense to<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;">> disable vzeroupper generation in general, but it simply doesn't make sense<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;">> on most platforms.<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;"> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;">I am confused by this point. By "most systems," do you have in mind a platform<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;">where the sin() function was compiled by gcc but the application codes were<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;">compiled by clang?<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;"> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;">If the sin() function was compiled by clang for a platform that supports AVX<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;">instructions, I do not expect it to contain legacy SSE instructions. Is it not<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;">the case for your platform?<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;"> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;">I just looked at the library code for our sin() function and I do not see any<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;">legacy SSE instructions (but for license restrictions I cannot share our<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;">library codes; sorry).<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;"> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;">> If you want a mechanism to disable vzeroupper generation for particular<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;">> function calls, that might make sense...<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;">> -Eli<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9.5pt; font-family: Consolas;"> </span></div></div>_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:LLVMdev@cs.uiuc.edu" style="color: purple; text-decoration: underline;">LLVMdev@cs.uiuc.edu</a><span class="Apple-converted-space"> </span>        <a href="http://llvm.cs.uiuc.edu/" style="color: purple; text-decoration: underline;">http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" style="color: purple; text-decoration: underline;">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a></div></blockquote></div><br></div></body></html>