Reid Kleckner
2013-Dec-19 20:36 UTC
[LLVMdev] [cfe-dev] [Proposal] function attribute to reduce emission of vzeroupper instructions
On Thu, Dec 19, 2013 at 12:14 PM, Rafael Espíndola < rafael.espindola at gmail.com> wrote:> On 19 December 2013 14:31, Gao, Yunzhong > <yunzhong_gao at playstation.sony.com> wrote: > > Hi all, > > > > > > > > I would like to find out whether anyone will find it useful to add an > x86- > > > > specific calling convention for reducing emission of vzeroupper > > instructions. > > > > > > > > Current implementation: > > > > vzeroupper is inserted to any functions that use AVX instructions. The > > > > insertion points are: > > > > 1) before a call instruction; > > > > 2) before a return instruction; > > > > > > > > Background: > > > > vzeroupper is an AVX instruction; it is inserted to avoid performance > > penalty > > > > when transitioning between x86 AVX mode and legacy SSE mode, e.g., when > an > > > > AVX function calls a SSE function. However, vzeroupper is a slow > > instruction; it > > > > adds to register pressure and hurts performance for AVX-to-AVX calls. > > > > > > > > My proposal: > > > > 1) (LLVM part) Add an x86-specific calling convention to the LLVM IR > which > > > > specifies that an external function will be compiled with AVX support and > > its > > > > function definition does not use any legacy SSE instructions, e.g., > > > > declare x86_avxcc i32 @foo() > > I would suggest using metadata instead. The reasons are: > > * It could be applied to functions with different calling conventions. > For example, on windows we would probably want to do this to thiscall > (methods) too. > * It the metadata is dropped, we would just produced slower but still > correct code (calls vzeroupper). >Maybe a target-specific attribute instead? It would still apply to all CCs, but would never be dropped. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131219/83099eb2/attachment.html>
Rafael Espíndola
2013-Dec-19 20:55 UTC
[LLVMdev] [cfe-dev] [Proposal] function attribute to reduce emission of vzeroupper instructions
> Maybe a target-specific attribute instead? It would still apply to all CCs, > but would never be dropped.That would work too, yes. I proposed metadata because it looks like it can be dropped, but that is not a big issue. I would be OK with an attribute too if that is more convenient or we want to make sure it is kept. Cheers, Rafael
Gao, Yunzhong
2013-Dec-21 02:42 UTC
[LLVMdev] [cfe-dev] [Proposal] function attribute to reduce emission of vzeroupper instructions
Hi Rafael and Reid, To clarify, With a target-specific attribute, the LLVM IR representation will be something like this: declare i32 @foo() "x86_avx"="true" With a target-specific metadata, the IR will be something like this: declare i32 @foo() !1 ... !1 = metadata !{metadata !"x86_avx"} If a backend does not understand this attribute or this metadata, it will have no effect on code generation. If this is what you mean, then I believe either approach will work for me. Do you have any opinion on the clang part of the proposal? I plan to take the next two weeks off from work, so I probably will respond to emails only sporadically. I hope you have a happy holiday there too, - Gao. _______________________________________ From: Rafael Espíndola [rafael.espindola at gmail.com] Sent: Thursday, December 19, 2013 12:55 PM To: Reid Kleckner Cc: Gao, Yunzhong; cfe-dev at cs.uiuc.edu Developers (cfe-dev at cs.uiuc.edu); LLVM Developers Mailing List (llvmdev at cs.uiuc.edu) Subject: Re: [cfe-dev] [LLVMdev] [Proposal] function attribute to reduce emission of vzeroupper instructions> Maybe a target-specific attribute instead? It would still apply to all CCs, > but would never be dropped.That would work too, yes. I proposed metadata because it looks like it can be dropped, but that is not a big issue. I would be OK with an attribute too if that is more convenient or we want to make sure it is kept. Cheers, Rafael
Reasonably Related Threads
- [LLVMdev] [cfe-dev] [Proposal] function attribute to reduce emission of vzeroupper instructions
- [LLVMdev] [Proposal] function attribute to reduce emission of vzeroupper instructions
- [LLVMdev] [Proposal] function attribute to reduce emission of vzeroupper instructions
- [LLVMdev] [cfe-dev] [Proposal] function attribute to reduce emission of vzeroupper instructions
- [LLVMdev] Proposal to improve vzeroupper optimization strategy