Re:New optimizations for X86 in upcoming GCC 5.0: PIC in 32 ...
by vardump on Wednesday April 15, 2015 @11:58AM
(#9381828)
Yes, you can use ESP in tight loops, done so many times in the past for software texture mapping, image processing, etc., but... debugging it is not fun. Where's my stack frame? Wouldn't want to use it in 2015.
Luckily in 2015 (=x86-64) you have 14 or 15 GP registers and 16 128-bit (or 256-bit) vector registers. While still keeping immediate values too, those don't consume a register. So much breathing space.
I guess they took the "ebx is reserved for the GOT address" part of the ABI a bit too literally... The ABI only specifies what happens at the interface; it doesn't matter at all what goes on "inside" as long as the right values end up in the right places at the right times. It's somewhat reminiscent of some older compilers that would obstinately refuse to use ebp for anything other than a pointer for accessing local variables and parameters.
You can even use esp if you set things up correctly, and I'm not the only one who has done this:
http://www.virtualdub.org/blog/pivot/entry.php?id=85
But I don't expect compilers to reach that level of insight anytime soon...