News for hackers. Stuff that matters.
Re:New optimizations for X86 in upcoming GCC 5.0: PIC in 32 ... by userbinator on Wednesday April 15, 2015 @07:30AM (#9380186)
As someone who has done a lot of Asm it's funny to see these sorts of things being called optimisations - one of the first things you learn is that the registers are for often-used values, so if you have a value in a register that won't be used often, it should be put somewhere else like the stack to make room for one that will be; keeping a register "dead" while repeatedly making memory accesses for something else that should be in a register just doesn't make any sense. It's like a form of pessimisation. Incidentally, this is also one of the ways to easily spot compiler-generated code.

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...

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.