<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Dec 19, 2013 at 12:14 PM, Rafael Espíndola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 19 December 2013 14:31, Gao, Yunzhong<br>
<div class="im"><<a href="mailto:yunzhong_gao@playstation.sony.com">yunzhong_gao@playstation.sony.com</a>> wrote:<br>
> Hi all,<br>
><br>
><br>
><br>
> I would like to find out whether anyone will find it useful to add an x86-<br>
><br>
> specific calling convention for reducing emission of vzeroupper<br>
> instructions.<br>
><br>
><br>
><br>
> Current implementation:<br>
><br>
> vzeroupper is inserted to any functions that use AVX instructions. The<br>
><br>
> insertion points are:<br>
><br>
> 1) before a call instruction;<br>
><br>
> 2) before a return instruction;<br>
><br>
><br>
><br>
> Background:<br>
><br>
> vzeroupper is an AVX instruction; it is inserted to avoid performance<br>
> penalty<br>
><br>
> when transitioning between x86 AVX mode and legacy SSE mode, e.g., when an<br>
><br>
> AVX function calls a SSE function. However, vzeroupper is a slow<br>
> instruction; it<br>
><br>
> adds to register pressure and hurts performance for AVX-to-AVX calls.<br>
><br>
><br>
><br>
> My proposal:<br>
><br>
> 1) (LLVM part) Add an x86-specific calling convention to the LLVM IR which<br>
><br>
> specifies that an external function will be compiled with AVX support and<br>
> its<br>
><br>
> function definition does not use any legacy SSE instructions, e.g.,<br>
><br>
>   declare x86_avxcc i32 @foo()<br>
<br>
</div>I would suggest using metadata instead. The reasons are:<br>
<br>
* It could be applied to functions with different calling conventions.<br>
For example, on windows we would probably want to do this to thiscall<br>
(methods) too.<br>
* It the metadata is dropped, we would just produced slower but still<br>
correct code (calls vzeroupper).<br></blockquote><div><br></div><div>Maybe a target-specific attribute instead?  It would still apply to all CCs, but would never be dropped. </div></div></div></div>