Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

In GCC you can actually offload the decision about which registers to choose if you are writing inline assembly code. You just specify what type of registers you need and GCC optimizes the assignments for you. Then you reference them with % notation - e.g. movd %1, %2. Imagine you provide this as an inline function in C++; all the calls for simple functions like arithmetic operations will be optimized on the spot instead of building stacks or moving some value to/from eax... It sped up my 3D software renderer more than twice! :)


You can also do the reverse. By adding __asm__("%ecx") to a variable declaration, you assign it to that register, while being able to perform C code as usual.

This usually results in degradation performance-wise, but has its uses.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: