Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get GCC to use more than two SIMD registers when using intrinsics?

I am writing some code and trying to speed it up using SIMD intrinsics SSE2/3. My code is of such nature that I need to load some data into an XMM register and act on it many times. When I'm looking at the assembler code generated, it seems that GCC keeps flushing the data back to the memory, in order to reload something else in XMM0 and XMM1. I am compiling for x86-64 so I have 15 registers. Why is GCC using only two and what can I do to ask it to use more? Is there any way that I can "pin" some value in a register? I added the "register" keyword to my variable definition, but the generated assembly code is identical.

like image 229
florin Avatar asked Sep 23 '08 22:09

florin


2 Answers

Yes, you can. Explicit Reg Vars talks about the syntax you need to pin a variable to a specific register.

like image 68
Chris Jester-Young Avatar answered Sep 22 '22 18:09

Chris Jester-Young


If you're getting to the point where you're specifying individual registers for each intrinsic, you might as well just write the assembly directory, especially given gcc's nasty habit of pessimizing intrinsics unnecessarily in many cases.

like image 25
Dark Shikari Avatar answered Sep 21 '22 18:09

Dark Shikari