<div dir="ltr">Is it realistic to worry about performance of vectorized code that does PIC calls into a non-vectorized sin() in libc? Maybe there's an example other than sin() that is more realistic?<div><br></div><div>
-- Sean Silva<br><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Sep 20, 2013 at 7:11 PM, Eli Friedman <span dir="ltr"><<a href="mailto:eli.friedman@gmail.com" target="_blank">eli.friedman@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="im">On Fri, Sep 20, 2013 at 2:58 PM, Gao, Yunzhong <span dir="ltr"><<a href="mailto:yunzhong_gao@playstation.sony.com" target="_blank">yunzhong_gao@playstation.sony.com</a>></span> wrote:<br>
</div><div class="gmail_extra">
<div class="gmail_quote"><div class="im"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-US" link="blue" vlink="purple">
<div>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">Hi Eli,<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">Thanks for the feedback. Please see below.<br>
- Gao.<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">From: Eli Friedman [mailto:<a href="mailto:eli.friedman@gmail.com" target="_blank">eli.friedman@gmail.com</a>]
<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">Sent: Thursday, September 19, 2013 12:31 PM<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">To: Gao, Yunzhong<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">Cc: <a href="mailto:llvmdev@cs.uiuc.edu" target="_blank">llvmdev@cs.uiuc.edu</a><u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">Subject: Re: [LLVMdev] Proposal to improve vzeroupper optimization strategy<u></u><u></u></span></p><div>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">> This is essentially equivalent to "don't insert vzeroupper anywhere", as<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">> far as I can tell. (The case of SSE instructions without a v- prefixed<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">> equivalent is rare enough we can separate it from this discussion.)<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"><u></u> <u></u></span></p>
</div><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">So will you be interested in a patch that disables vzeroupper by default?</span></p></div></div></blockquote><div>
<br></div></div><div>A patch which adds a switch/LLVM IR function attribute to disable vzeroupper would be fine. A patch that disables vzeroupper on your platform would be fine (assuming the target triple is distinguishable). Turning off vzeroupper by default on all platforms is not fine.</div>
<div class="im">
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple">
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">I implemented this possibly over-engineering solution in our local tree to work<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">around some bad instruction selection issues in LLVM backend. When benchmarking<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">on our game codes, I noticed that sometimes legacy SSE instructions were<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">selected despite existence of AVX equivalent, in which case the vzeroupper<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">instruction was needed. And it is much easier to detect existence of vzeroupper<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">instruction than to detect each single legacy SSE instructions.<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">The instruction selection issues were later fixed in our tree (patches to be<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">submitted later), at least for the handful of games I tested on. So a simple<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">change to just disable vzeroupper by default will be acceptable to us as well.<u></u><u></u></span></p><div>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">> The reason we need vzeroupper in the first place is because we can't assume<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">> other functions won't use legacy SSE instructions; for example, on most<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">> systems, calling sin() will use legacy SSE instructions. I mean, if you can<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">> make some unusual guarantee about your platform, it might make sense to<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">> disable vzeroupper generation in general, but it simply doesn't make sense<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">> on most platforms.<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"><u></u> <u></u></span></p>
</div><p class="MsoNormal" style="text-autospace:none"><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<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">where the sin() function was compiled by gcc but the application codes were<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">compiled by clang?</span></p></div></blockquote><div><br></div></div><div>On, for example, OS X, AVX is not enabled by default, so the sin() function uses legacy SSE instructions. Users can still turn on AVX in their applications.</div>
<span class="HOEnZb"><font color="#888888">
<div><br></div><div>-Eli</div></font></span></div></div></div>
<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div><br></div></div></div>